Merge pull request #4849 from wisp3rwind/pr_add_syspath_3

Always use syspath conversions (#3690 split up, part 3)
This commit is contained in:
Adrian Sampson 2023-07-18 13:14:35 -07:00 committed by GitHub
commit efebd72ca9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View file

@ -392,7 +392,8 @@ class ImportSession:
"""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)
@ -921,7 +922,7 @@ class ImportTask(BaseImportTask):
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())
@ -1131,7 +1132,7 @@ class ArchiveImportTask(SentinelImportTask):
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

View file

@ -1215,7 +1215,7 @@ class Album(LibModel):
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

View file

@ -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):
@ -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)