mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Removed unnecessary check
This commit is contained in:
		| @@ -420,36 +420,34 @@ def update_filename(sender, instance, **kwargs): | |||||||
|     if instance.filename == new_filename: |     if instance.filename == new_filename: | ||||||
|         return |         return | ||||||
|  |  | ||||||
|     # Check if filename needs changing |     # Determine the full "target" path | ||||||
|     if new_filename != instance.filename: |     path_new = instance.filename_to_path(new_filename) | ||||||
|         # Determine the full "target" path |     dir_new = instance.filename_to_path(os.path.dirname(new_filename)) | ||||||
|         path_new = instance.filename_to_path(new_filename) |  | ||||||
|         dir_new = instance.filename_to_path(os.path.dirname(new_filename)) |  | ||||||
|  |  | ||||||
|         # Create new path |     # Create new path | ||||||
|         instance.create_source_directory() |     instance.create_source_directory() | ||||||
|  |  | ||||||
|         # Determine the full "current" path |     # Determine the full "current" path | ||||||
|         path_current = instance.filename_to_path(instance.filename) |     path_current = instance.filename_to_path(instance.filename) | ||||||
|  |  | ||||||
|         # Move file |     # Move file | ||||||
|         try: |     try: | ||||||
|             os.rename(path_current, path_new) |         os.rename(path_current, path_new) | ||||||
|         except PermissionError: |     except PermissionError: | ||||||
|             # Do not update filename in object |         # Do not update filename in object | ||||||
|             return |         return | ||||||
|  |  | ||||||
|         # Delete empty directory |     # Delete empty directory | ||||||
|         old_dir = os.path.dirname(instance.filename) |     old_dir = os.path.dirname(instance.filename) | ||||||
|         old_path = instance.filename_to_path(old_dir) |     old_path = instance.filename_to_path(old_dir) | ||||||
|         delete_empty_directory(old_path) |     delete_empty_directory(old_path) | ||||||
|  |  | ||||||
|         instance.filename = new_filename |     instance.filename = new_filename | ||||||
|  |  | ||||||
|         # Save instance |     # Save instance | ||||||
|         # This will not cause a cascade of post_save signals, as next time |     # This will not cause a cascade of post_save signals, as next time | ||||||
|         # nothing needs to be renamed |     # nothing needs to be renamed | ||||||
|         instance.save() |     instance.save() | ||||||
|  |  | ||||||
|  |  | ||||||
| @receiver(models.signals.post_delete, sender=Document) | @receiver(models.signals.post_delete, sender=Document) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Wolf-Bastian Poettner
					Wolf-Bastian Poettner