diff --git a/py/app_se_cocoa.py b/py/app_se_cocoa.py index 618ed8b9..a07c7613 100644 --- a/py/app_se_cocoa.py +++ b/py/app_se_cocoa.py @@ -8,6 +8,7 @@ from hsfs.phys import Directory as DirectoryBase from hsfs.phys.bundle import Bundle from hsutil.path import Path +from hsutil.misc import extract from hsutil.str import get_file_ext @@ -15,13 +16,19 @@ from . import app_cocoa, data from .directories import Directories as DirectoriesBase, STATE_EXCLUDED class DGDirectory(DirectoryBase): - def _create_sub_dir(self, name, with_parent = True): + def _create_sub_file(self, name, with_parent=True): ext = get_file_ext(name) if ext == 'app': parent = self if with_parent else None return Bundle(parent, name) else: - return super(DGDirectory, self)._create_sub_dir(name, with_parent) + return super(DGDirectory, self)._create_sub_file(name, with_parent) + + def _fetch_subitems(self): + subdirs, subfiles = super(DGDirectory, self)._fetch_subitems() + apps, normal_dirs = extract(lambda name: get_file_ext(name) == 'app', subdirs) + subfiles += apps + return normal_dirs, subfiles class Directories(DirectoriesBase): diff --git a/py/scanner.py b/py/scanner.py index 9a7521c7..69a03b38 100644 --- a/py/scanner.py +++ b/py/scanner.py @@ -54,7 +54,11 @@ class Scanner(object): SCAN_TYPE_CONTENT_AUDIO: lambda f: [str(f.audiosize)] }[self.scan_type] for f in j.iter_with_progress(files, 'Read metadata of %d/%d files'): + if self.size_threshold: + f.size # pre-read, makes a smoother progress if read here (especially for bundles) f.words = func(f) + if self.size_threshold: + files = [f for f in files if f.size >= self.size_threshold] return mf.getmatches(files, j) @staticmethod @@ -75,8 +79,6 @@ class Scanner(object): j = j.start_subjob([8, 2]) for f in [f for f in files if not hasattr(f, 'is_ref')]: f.is_ref = False - if self.size_threshold: - files = [f for f in files if f.size >= self.size_threshold] logging.info('Getting matches') if self.match_factory is None: matches = self._getmatches(files, j)