Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use syspath conversions (#3690 split up, part 3) #4849

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions beets/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ def mark_merged(self, paths):
"""Mark paths and directories as merged for future reimport tasks.
"""
self._merged_items.update(paths)
dirs = {os.path.dirname(path) if os.path.isfile(path) else path
dirs = {os.path.dirname(path)
if os.path.isfile(syspath(path)) else path
for path in paths}
self._merged_dirs.update(dirs)

Expand Down Expand Up @@ -921,7 +922,7 @@ def prune(self, filename):
the file still exists, no pruning is performed, so it's safe to
call when the file in question may not have been removed.
"""
if self.toppath and not os.path.exists(filename):
if self.toppath and not os.path.exists(syspath(filename)):
util.prune_dirs(os.path.dirname(filename),
self.toppath,
clutter=config['clutter'].as_str_seq())
Expand Down Expand Up @@ -1131,7 +1132,7 @@ def cleanup(self, **kwargs):
if self.extracted:
log.debug('Removing extracted directory: {0}',
displayable_path(self.toppath))
shutil.rmtree(self.toppath)
shutil.rmtree(syspath(self.toppath))

def extract(self):
"""Extracts the archive to a temporary directory and sets
Expand Down
2 changes: 1 addition & 1 deletion beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ def move_art(self, operation=MoveOperation.MOVE):
if not old_art:
return

if not os.path.exists(old_art):
if not os.path.exists(syspath(old_art)):
log.error('removing reference to missing album art file {}',
util.displayable_path(old_art))
self.artpath = None
Expand Down
8 changes: 5 additions & 3 deletions beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ def update_items(lib, query, album, move, pretend, fields):

def update_func(lib, opts, args):
# Verify that the library folder exists to prevent accidental wipes.
if not os.path.isdir(lib.directory):
if not os.path.isdir(syspath(lib.directory)):
ui.print_("Library path is unavailable or does not exist.")
ui.print_(lib.directory)
if not ui.input_yn("Are you sure you want to continue (y/n)?", True):
Expand Down Expand Up @@ -1666,8 +1666,10 @@ def move_func(lib, opts, args):
dest = opts.dest
if dest is not None:
dest = normpath(dest)
if not os.path.isdir(dest):
raise ui.UserError('no such directory: %s' % dest)
if not os.path.isdir(syspath(dest)):
raise ui.UserError('no such directory: {}'.format(
displayable_path(dest)
))

move_items(lib, dest, decargs(args), opts.copy, opts.album, opts.pretend,
opts.timid, opts.export)
Expand Down