-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfix_duplicates.py
More file actions
34 lines (26 loc) · 872 Bytes
/
Copy pathfix_duplicates.py
File metadata and controls
34 lines (26 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from app.models import UploadedFile
groups = {}
for f in UploadedFile.objects:
groups.setdefault(f.content_checksum, []).append(f)
for l in groups.values():
if len(l) < 2: continue
if not l[0].content_checksum:
for f in l:
if f.duplicate_of:
print('Fixed content checksumless', f.checksum)
f.duplicate_of = None
f.save()
continue
master = None
for f in l:
if f.vp_checksum:
master = f
break
if master:
print(master.content_checksum, '->', master.checksum, master.duplicate_of)
if master.expires != -1:
master.make_permanent()
for f in l:
if f.duplicate_of != master.checksum:
f.duplicate_of = master.checksum
f.save()