diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index f263256aa..d615e0116 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -91,7 +91,7 @@ def _sorted_walk(path): files = [] for base in os.listdir(path): cur = os.path.join(path, base) - if os.path.isdir(cur): + if os.path.isdir(library._syspath(cur)): dirs.append(base) else: files.append(base) diff --git a/beets/library.py b/beets/library.py index bbc738628..7d3e15af6 100644 --- a/beets/library.py +++ b/beets/library.py @@ -138,8 +138,8 @@ def _mkdirall(path): parent). """ for ancestor in _ancestry(path): - if not os.path.isdir(ancestor): - os.mkdir(ancestor) + if not os.path.isdir(_syspath(ancestor)): + os.mkdir(_syspath(ancestor)) def _components(path, pathmod=None): """Return a list of the path components in path. For instance: @@ -973,7 +973,7 @@ class Library(BaseLibrary): def remove(self, item, delete=False): self.conn.execute('DELETE FROM items WHERE id=?', (item.id,)) if delete: - os.unlink(item.path) + os.unlink(_syspath(item.path)) # Browsing. diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 438f769cc..a90b31675 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -315,9 +315,12 @@ def read_albums(paths): """A generator yielding all the albums (as sets of Items) found in the user-specified list of paths. """ + # Use absolute paths. + paths = [library._normpath(path) for path in paths] + # Check the user-specified directories. for path in paths: - if not os.path.isdir(path): + if not os.path.isdir(library._syspath(path)): raise ui.UserError('not a directory: ' + path) # Look for saved progress. resume_dirs = {} @@ -486,7 +489,7 @@ def apply_choices(lib, copy, write, art, delete): # Finally, delete old files. if copy and delete: for old_path in old_paths: - os.remove(old_path) + os.remove(library._syspath(old_path)) # Update progress. progress_set(toppath, path) @@ -513,7 +516,7 @@ def simple_import(lib, paths, copy, delete): if copy and delete: for old_path in old_paths: - os.remove(old_path) + os.remove(library._syspath(old_path)) log.info('added album: %s - %s' % (album.artist, album.album)) diff --git a/test/test_files.py b/test/test_files.py index b465efbda..b283e7241 100644 --- a/test/test_files.py +++ b/test/test_files.py @@ -171,7 +171,7 @@ class ArtFileTest(unittest.TestCase): def setUp(self): # Make library and item. self.lib = beets.library.Library(':memory:') - self.libdir = os.path.join('rsrc', 'testlibdir') + self.libdir = os.path.abspath(os.path.join('rsrc', 'testlibdir')) self.lib.directory = self.libdir self.i = item() self.i.path = self.lib.destination(self.i)