From 8f98b78cc218efc43426adaa92ded33611c10179 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Thu, 8 Feb 2024 12:57:59 -0500 Subject: [PATCH] Use copy2 if we need to own files after commit --- librarian_server/stores/local.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/librarian_server/stores/local.py b/librarian_server/stores/local.py index 63ca237..1df5e16 100644 --- a/librarian_server/stores/local.py +++ b/librarian_server/stores/local.py @@ -115,12 +115,16 @@ def unstage(self, path: Path): return def commit(self, staging_path: Path, store_path: Path): - shutil.move( + need_ownership_changes = self.own_after_commit or self.readonly_after_commit + + use_func_commit = shutil.copy2 if need_ownership_changes else shutil.move + + use_func_commit( self._resolved_path_staging(staging_path), self._resolved_path_store(store_path), ) - if not self.own_after_commit and not self.readonly_after_commit: + if not need_ownership_changes: return resolved_path = self._resolved_path_store(store_path)