Skip to content

Commit

Permalink
Use copy2 if we need to own files after commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Feb 8, 2024
1 parent b96ba3c commit 8f98b78
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions librarian_server/stores/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f98b78

Please sign in to comment.