In cases where a temporary file is created or used, copy the original file stats to it

This commit is contained in:
Trenton H
2023-05-26 13:50:41 -07:00
parent 36b4fff5c7
commit 883937bfd7
2 changed files with 8 additions and 1 deletions

View File

@@ -326,7 +326,7 @@ class Consumer(LoggingMixin):
dir=settings.SCRATCH_DIR,
)
self.path = Path(tempdir.name) / Path(self.filename)
shutil.copy(self.original_path, self.path)
shutil.copy2(self.original_path, self.path)
# Determine the parser class.
@@ -582,6 +582,7 @@ class Consumer(LoggingMixin):
def _write(self, storage_type, source, target):
with open(source, "rb") as read_file, open(target, "wb") as write_file:
write_file.write(read_file.read())
shutil.copystat(source, target)
def _log_script_outputs(self, completed_process: CompletedProcess):
"""