mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
Update directory scanning to use os.scandir()
- Change to use os.scandir() instead of os.walk() to leverage DirEntry objects. - Avoids extra calls to stat() on files during fs.can_handle() - See 3x speed improvement on Windows in some cases
This commit is contained in:
@@ -379,7 +379,7 @@ class Folder(File):
|
||||
if self._subfolders is None:
|
||||
with os.scandir(self.path) as iter:
|
||||
subfolders = [p.path for p in iter if not p.is_symlink() and p.is_dir()]
|
||||
self._subfolders = [self.__class__(p) for p in subfolders]
|
||||
self._subfolders = [self.__class__(Path(p)) for p in subfolders]
|
||||
return self._subfolders
|
||||
|
||||
@classmethod
|
||||
@@ -398,7 +398,7 @@ def get_file(path, fileclasses=[File]):
|
||||
for fileclass in fileclasses:
|
||||
if fileclass.can_handle(path):
|
||||
if type(path) is os.DirEntry:
|
||||
return fileclass(path.path)
|
||||
return fileclass(Path(path.path))
|
||||
return fileclass(path)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user