mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 12:35:19 +01:00
singleton imports can take single-file arguments (#184)
This commit is contained in:
parent
69f392c8f2
commit
3b23198324
3 changed files with 14 additions and 3 deletions
2
NEWS
2
NEWS
|
|
@ -17,6 +17,8 @@
|
|||
respected in BPD's browsing hierarchy. This may come at a performance
|
||||
cost, however. The virtual filesystem used by BPD is available for
|
||||
reuse by plugins (e.g., the FUSE plugin).
|
||||
* Singleton imports ("beet import -s") can now take individual files as
|
||||
arguments as well as directories.
|
||||
* Fix crash when autotagging files with no metadata.
|
||||
* Fix a rare deadlock when finishing the import pipeline.
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,8 @@ class ImportTask(object):
|
|||
|
||||
def read_tasks(config):
|
||||
"""A generator yielding all the albums (as ImportTask objects) found
|
||||
in the user-specified list of paths.
|
||||
in the user-specified list of paths. In the case of a singleton
|
||||
import, yields single-item tasks instead.
|
||||
"""
|
||||
# Look for saved progress.
|
||||
progress = config.resume is not False
|
||||
|
|
@ -336,7 +337,13 @@ def read_tasks(config):
|
|||
progress_set(path, None)
|
||||
|
||||
for toppath in config.paths:
|
||||
# Produce each path.
|
||||
# Check whether the path is to a file.
|
||||
if config.singletons and not os.path.isdir(syspath(toppath)):
|
||||
item = library.Item.from_path(toppath)
|
||||
yield ImportTask.item_task(item)
|
||||
continue
|
||||
|
||||
# Produce paths under this directory.
|
||||
if progress:
|
||||
resume_dir = resume_dirs.get(toppath)
|
||||
for path, items in autotag.albums_in_dir(toppath):
|
||||
|
|
|
|||
|
|
@ -417,8 +417,10 @@ def import_files(lib, paths, copy, write, autot, logpath, art, threaded,
|
|||
"""
|
||||
# Check the user-specified directories.
|
||||
for path in paths:
|
||||
if not os.path.isdir(syspath(path)):
|
||||
if not singletons and not os.path.isdir(syspath(path)):
|
||||
raise ui.UserError('not a directory: ' + path)
|
||||
elif singletons and not os.path.exists(syspath(path)):
|
||||
raise ui.UserError('no such file: ' + path)
|
||||
|
||||
# Check parameter consistency.
|
||||
if quiet and timid:
|
||||
|
|
|
|||
Loading…
Reference in a new issue