Use bytes for destination base name

This is mostly "defensive programming": clients *should* only call this
on bytestring paths, but just in case this gets called on a Unicode
string path, we should now not crash.
This commit is contained in:
Adrian Sampson 2021-12-27 13:51:42 -08:00
parent 592c3fa356
commit de3eedc033
No known key found for this signature in database
GPG key ID: BDB93AB409CC8705

View file

@ -496,8 +496,9 @@ def move(path, dest, replace=False):
os.replace(path, dest)
except OSError:
# Copy the file to a temporary destination.
base = os.path.basename(bytestring_path(dest))
tmp = tempfile.NamedTemporaryFile(suffix=b'.beets',
prefix=b'.' + os.path.basename(dest),
prefix=b'.' + base,
dir=os.path.dirname(dest),
delete=False)
try: