mirror of
https://github.com/beetbox/beets.git
synced 2026-01-07 16:34:45 +01:00
Add ignore_hidden configuration property
Add `ignore_hidden` top level configuration property, allowing hidden files to be ignored on import.
This commit is contained in:
parent
412bde5de2
commit
4b4e788865
3 changed files with 13 additions and 7 deletions
|
|
@ -26,6 +26,7 @@ import:
|
|||
|
||||
clutter: ["Thumbs.DB", ".DS_Store"]
|
||||
ignore: [".*", "*~", "System Volume Information"]
|
||||
ignore_hidden: yes
|
||||
replace:
|
||||
'[\\/]': _
|
||||
'^\.': _
|
||||
|
|
|
|||
|
|
@ -1451,8 +1451,11 @@ def albums_in_dir(path):
|
|||
"""
|
||||
collapse_pat = collapse_paths = collapse_items = None
|
||||
ignore = config['ignore'].as_str_seq()
|
||||
ignore_hidden = config['ignore_hidden'].get(bool)
|
||||
|
||||
for root, dirs, files in sorted_walk(path, ignore=ignore, logger=log):
|
||||
for root, dirs, files in sorted_walk(path, ignore=ignore,
|
||||
ignore_hidden=ignore_hidden,
|
||||
logger=log):
|
||||
items = [os.path.join(root, f) for f in files]
|
||||
# If we're currently collapsing the constituent directories in a
|
||||
# multi-disc album, check whether we should continue collapsing
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import traceback
|
|||
import subprocess
|
||||
import platform
|
||||
import shlex
|
||||
from beets.util import hidden
|
||||
|
||||
|
||||
MAX_FILENAME_LENGTH = 200
|
||||
|
|
@ -151,7 +152,7 @@ def ancestry(path):
|
|||
return out
|
||||
|
||||
|
||||
def sorted_walk(path, ignore=(), logger=None):
|
||||
def sorted_walk(path, ignore=(), ignore_hidden=False, logger=None):
|
||||
"""Like `os.walk`, but yields things in case-insensitive sorted,
|
||||
breadth-first order. Directory and file names matching any glob
|
||||
pattern in `ignore` are skipped. If `logger` is provided, then
|
||||
|
|
@ -185,10 +186,11 @@ def sorted_walk(path, ignore=(), logger=None):
|
|||
|
||||
# Add to output as either a file or a directory.
|
||||
cur = os.path.join(path, base)
|
||||
if os.path.isdir(syspath(cur)):
|
||||
dirs.append(base)
|
||||
else:
|
||||
files.append(base)
|
||||
if (ignore_hidden and not hidden.is_hidden(cur)) or not ignore_hidden:
|
||||
if os.path.isdir(syspath(cur)):
|
||||
dirs.append(base)
|
||||
else:
|
||||
files.append(base)
|
||||
|
||||
# Sort lists (case-insensitive) and yield the current level.
|
||||
dirs.sort(key=bytes.lower)
|
||||
|
|
@ -199,7 +201,7 @@ def sorted_walk(path, ignore=(), logger=None):
|
|||
for base in dirs:
|
||||
cur = os.path.join(path, base)
|
||||
# yield from sorted_walk(...)
|
||||
for res in sorted_walk(cur, ignore, logger):
|
||||
for res in sorted_walk(cur, ignore, ignore_hidden, logger):
|
||||
yield res
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue