Skip to content

Commit

Permalink
add missing syspath conversions (3/3, beets)
Browse files Browse the repository at this point in the history
  • Loading branch information
wisp3rwind committed Jul 16, 2023
1 parent b19b961 commit b58ab90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
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

0 comments on commit b58ab90

Please sign in to comment.