Fix: trigger move and rename after custom fields saved (#7927)

This commit is contained in:
shamoon 2024-10-15 10:08:50 -07:00 committed by GitHub
parent 7e623e6e4e
commit 808ba4cb68

View File

@ -364,9 +364,17 @@ class CannotMoveFilesException(Exception):
pass
@receiver(models.signals.post_save, sender=CustomFieldInstance)
@receiver(models.signals.m2m_changed, sender=Document.tags.through)
@receiver(models.signals.post_save, sender=Document)
def update_filename_and_move_files(sender, instance: Document, **kwargs):
def update_filename_and_move_files(
sender,
instance: Document | CustomFieldInstance,
**kwargs,
):
if isinstance(instance, CustomFieldInstance):
instance = instance.document
def validate_move(instance, old_path, new_path):
if not os.path.isfile(old_path):
# Can't do anything if the old file does not exist anymore.