From a0ca4b5694f43c63ea13ba6908eff2bd53ee7ebb Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 19 Aug 2018 20:21:57 -0300 Subject: Fixed #29689 -- Improved performance of FileSystemStorage.listdir() and FilePathField with os.scandir(). --- tests/staticfiles_tests/storage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py index 7a1f72c130..3214a68a00 100644 --- a/tests/staticfiles_tests/storage.py +++ b/tests/staticfiles_tests/storage.py @@ -39,11 +39,11 @@ class PathNotImplementedStorage(storage.Storage): def listdir(self, path): path = self._path(path) directories, files = [], [] - for entry in os.listdir(path): - if os.path.isdir(os.path.join(path, entry)): - directories.append(entry) + for entry in os.scandir(path): + if entry.is_dir(): + directories.append(entry.name) else: - files.append(entry) + files.append(entry.name) return directories, files def delete(self, name): -- cgit v1.3