Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloud_storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2024, AgriTheory and contributors
# For license information, please see license.txt

__version__ = "15.7.2"
__version__ = "15.7.3"


import frappe.desk.form.load
Expand Down
16 changes: 12 additions & 4 deletions cloud_storage/cloud_storage/overrides/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def validate(self) -> None:
PATH: frappe/core/doctype/file/file.py
METHOD: validate
"""
self.associate_files()
# guard against recursion: associate_files() can save another File, re-entering validate
if not self.flags.associating_files:
self.associate_files()
if self.flags.cloud_storage or self.flags.ignore_file_validate:
return
if not self.is_remote_file:
Expand Down Expand Up @@ -228,10 +230,16 @@ def associate_files(
existing_file = frappe.get_doc("File", associated_doc)
existing_file.attached_to_doctype = attached_to_doctype
existing_file.attached_to_name = attached_to_name
existing_file.append(
"file_association",
add_child_file_association(attached_to_doctype, attached_to_name),
already_linked = any(
assoc.link_doctype == attached_to_doctype and assoc.link_name == attached_to_name
for assoc in existing_file.file_association
)
if not already_linked:
existing_file.append(
"file_association",
add_child_file_association(attached_to_doctype, attached_to_name),
)
existing_file.flags.associating_files = True
existing_file.save()
else:
if self.file_association:
Expand Down
Loading