Skip to content

Commit

Permalink
Write to a temp filename in posix file source plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Jan 24, 2024
1 parent c078220 commit 07d517e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/galaxy/files/sources/posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ def _write_from(
target_native_path = os.path.normpath(target_native_path)
assert target_native_path.startswith(os.path.normpath(effective_root))

target_native_path_parent = os.path.dirname(target_native_path)
target_native_path_parent, target_native_path_name = os.path.split(target_native_path)
if not os.path.exists(target_native_path_parent):
if self.allow_subdir_creation:
os.makedirs(target_native_path_parent)
else:
raise Exception("Parent directory does not exist.")

shutil.copyfile(native_path, target_native_path)
target_native_path_part = os.path.join(target_native_path_parent, f"_{target_native_path_name}.part")
shutil.copyfile(native_path, target_native_path_part)
os.rename(target_native_path_part, target_native_path)

def _to_native_path(self, source_path: str, user_context=None):
source_path = os.path.normpath(source_path)
Expand Down

0 comments on commit 07d517e

Please sign in to comment.