mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	[#25 state:fixed] Adjusted to the change in hsfs:[4] (Bundle change). It allows to leverage the File caching system, thus fixing #25.
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4029
This commit is contained in:
		
							parent
							
								
									6a4a93f767
								
							
						
					
					
						commit
						ba75f3243d
					
				@ -8,6 +8,7 @@
 | 
				
			|||||||
from hsfs.phys import Directory as DirectoryBase
 | 
					from hsfs.phys import Directory as DirectoryBase
 | 
				
			||||||
from hsfs.phys.bundle import Bundle
 | 
					from hsfs.phys.bundle import Bundle
 | 
				
			||||||
from hsutil.path import Path
 | 
					from hsutil.path import Path
 | 
				
			||||||
 | 
					from hsutil.misc import extract
 | 
				
			||||||
from hsutil.str import get_file_ext
 | 
					from hsutil.str import get_file_ext
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -15,13 +16,19 @@ from . import app_cocoa, data
 | 
				
			|||||||
from .directories import Directories as DirectoriesBase, STATE_EXCLUDED
 | 
					from .directories import Directories as DirectoriesBase, STATE_EXCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DGDirectory(DirectoryBase):
 | 
					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)
 | 
					        ext = get_file_ext(name)
 | 
				
			||||||
        if ext == 'app':
 | 
					        if ext == 'app':
 | 
				
			||||||
            parent = self if with_parent else None
 | 
					            parent = self if with_parent else None
 | 
				
			||||||
            return Bundle(parent, name)
 | 
					            return Bundle(parent, name)
 | 
				
			||||||
        else:
 | 
					        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):
 | 
					class Directories(DirectoriesBase):
 | 
				
			||||||
 | 
				
			|||||||
@ -54,7 +54,11 @@ class Scanner(object):
 | 
				
			|||||||
            SCAN_TYPE_CONTENT_AUDIO: lambda f: [str(f.audiosize)]
 | 
					            SCAN_TYPE_CONTENT_AUDIO: lambda f: [str(f.audiosize)]
 | 
				
			||||||
        }[self.scan_type]
 | 
					        }[self.scan_type]
 | 
				
			||||||
        for f in j.iter_with_progress(files, 'Read metadata of %d/%d files'):
 | 
					        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)
 | 
					            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)
 | 
					        return mf.getmatches(files, j)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
@ -75,8 +79,6 @@ class Scanner(object):
 | 
				
			|||||||
        j = j.start_subjob([8, 2])
 | 
					        j = j.start_subjob([8, 2])
 | 
				
			||||||
        for f in [f for f in files if not hasattr(f, 'is_ref')]:
 | 
					        for f in [f for f in files if not hasattr(f, 'is_ref')]:
 | 
				
			||||||
            f.is_ref = False
 | 
					            f.is_ref = False
 | 
				
			||||||
        if self.size_threshold:
 | 
					 | 
				
			||||||
            files = [f for f in files if f.size >= self.size_threshold]
 | 
					 | 
				
			||||||
        logging.info('Getting matches')
 | 
					        logging.info('Getting matches')
 | 
				
			||||||
        if self.match_factory is None:
 | 
					        if self.match_factory is None:
 | 
				
			||||||
            matches = self._getmatches(files, j)
 | 
					            matches = self._getmatches(files, j)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user