Merge pull request #31360 from sokumon/attach-file-spam-issue
fix: check if duplicate_file url matches incoming file url
This commit is contained in:
commit
0040c7f852
1 changed files with 5 additions and 3 deletions
|
|
@ -386,8 +386,6 @@ class File(Document):
|
|||
|
||||
if self.name:
|
||||
filters.update({"name": ("!=", self.name)})
|
||||
else:
|
||||
filters.update({"file_name": self.file_name})
|
||||
|
||||
if self.attached_to_doctype and self.attached_to_name:
|
||||
filters.update(
|
||||
|
|
@ -663,7 +661,11 @@ class File(Document):
|
|||
if duplicate_file:
|
||||
file_doc: File = frappe.get_cached_doc("File", duplicate_file.name)
|
||||
if file_doc.exists_on_disk():
|
||||
self.file_url = duplicate_file.file_url
|
||||
if self.exists_on_disk():
|
||||
if not self.file_url:
|
||||
self.file_url = duplicate_file.file_url
|
||||
else:
|
||||
self.file_url = duplicate_file.file_url
|
||||
file_exists = True
|
||||
|
||||
if not file_exists:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue