Skip to content

Commit

Permalink
[#261] Prevent Delete Mode with mapped paths
Browse files Browse the repository at this point in the history
Whenever a path will be modified due to UnicodeEncodeError
handling or a character_map event handler method is defined,
the Delete Mode feature should be disabled to prevent data
loss. Support for these combinations of features will be
implemented in the future.
  • Loading branch information
alanking committed Oct 10, 2024
1 parent ccd26ae commit e289dc2
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions irods_capability_automated_ingest/tasks/filesystem_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,37 @@ def filesystem_sync_path(self, meta):

delete_extraneous_items = utils.DeleteMode.DO_NOT_DELETE != delete_mode
if delete_extraneous_items:
subcollections_in_collection, data_objects_in_collection = (
get_collections_and_data_objects_in_collection(
meta, destination_collection
# TODO(#261): Prevent Delete Mode usage with character_map until support is implemented.
character_map = getattr(event_handler.get_module(), "character_map", None)
if character_map:
logger.warning(
"character_map and non-default Delete Mode are incompatible at this time. "
"Delete Mode will be disabled for this task."
)
delete_extraneous_items = False
else:
subcollections_in_collection, data_objects_in_collection = (
get_collections_and_data_objects_in_collection(
meta, destination_collection
)
)
)
else:
subcollections_in_collection = []
data_objects_in_collection = []

for obj in itr:
full_path = os.path.abspath(obj.path)

# TODO(#261): Prevent Delete Mode usage when any path is modified due to UnicodeEncodeError until support is
# implemented.
if delete_extraneous_items:
if utils.is_unicode_encode_error_path(full_path):
logger.warning(
"Found a path which will be modified due to UnicodeEncodeError. "
"Delete Mode does not support this and so will be disabled for this task."
)
delete_extraneous_items = False

mode = obj.stat(follow_symlinks=False).st_mode

if exclude_file_type(
Expand Down

0 comments on commit e289dc2

Please sign in to comment.