Skip to content

Commit

Permalink
Add a copystat call in beet's util move, to copy permissions.
Browse files Browse the repository at this point in the history
  • Loading branch information
aereaux committed Mar 22, 2024
1 parent b09806e commit f622bd8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions beets/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,7 @@ def copy(path: bytes, dest: bytes, replace: bool = False):
def move(path: bytes, dest: bytes, replace: bool = False):
"""Rename a file. `dest` may not be a directory. If `dest` already
exists, raises an OSError unless `replace` is True. Has no effect if
`path` is the same as `dest`. If the paths are on different
filesystems (or the rename otherwise fails), a copy is attempted
instead, in which case metadata will *not* be preserved. Paths are
translated to system paths.
`path` is the same as `dest`. Paths are translated to system paths.
"""
if os.path.isdir(syspath(path)):
raise FilesystemError("source is directory", "move", (path, dest))
Expand Down Expand Up @@ -536,6 +533,9 @@ def move(path: bytes, dest: bytes, replace: bool = False):
finally:
tmp.close()

# Copy file metadata
shutil.copystat(syspath(path), tmp.name)

# Move the copied file into place.
try:
os.replace(tmp.name, syspath(dest))
Expand Down

0 comments on commit f622bd8

Please sign in to comment.