Reuse existing files as previews, icons or featured images #161
@ -188,16 +188,16 @@ class ExtensionUpdateForm(forms.ModelForm):
|
|||||||
self.icon_form,
|
self.icon_form,
|
||||||
]
|
]
|
||||||
seen_hashes = {}
|
seen_hashes = {}
|
||||||
for f in new_file_forms:
|
|
||||||
hash = f.instance.original_hash
|
|
||||||
if hash and hash not in seen_hashes:
|
|
||||||
seen_hashes[hash] = f.instance
|
|
||||||
# Ignore duplicate files in the formsets: point all forms sharing the hash to the same
|
# Ignore duplicate files in the formsets: point all forms sharing the hash to the same
|
||||||
# file instance, when forms call .save() it'll be on the same instance.
|
# file instance, when forms call .save() it'll be on the same instance.
|
||||||
for f in new_file_forms:
|
for f in new_file_forms:
|
||||||
hash = f.instance.original_hash
|
hash = f.instance.original_hash
|
||||||
if hash:
|
if not hash:
|
||||||
|
continue
|
||||||
|
if hash in seen_hashes:
|
||||||
f.instance = seen_hashes[hash]
|
f.instance = seen_hashes[hash]
|
||||||
|
else:
|
||||||
|
seen_hashes[hash] = f.instance
|
||||||
return all(is_valid_flags)
|
return all(is_valid_flags)
|
||||||
|
|
||||||
def clean_team(self):
|
def clean_team(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user