File tree 1 file changed +7
-1
lines changed
tagstudio/src/core/library/json
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -304,6 +304,8 @@ class Library:
304
304
def __init__ (self ) -> None :
305
305
# Library Info =========================================================
306
306
self .library_dir : Path = None
307
+ # Cached result of os.walk when relinking library files
308
+ self ._library_file_cache : list [(string , list [string ], list [string ])] = None
307
309
308
310
# Entries ==============================================================
309
311
# List of every Entry object.
@@ -1092,6 +1094,7 @@ def fix_missing_files(self):
1092
1094
yield (i , True )
1093
1095
else :
1094
1096
yield (i , False )
1097
+ self ._library_file_cache = None
1095
1098
1096
1099
# self._purge_empty_missing_entries()
1097
1100
@@ -1124,9 +1127,12 @@ def _match_missing_file(self, file: str) -> list[Path]:
1124
1127
1125
1128
matches = []
1126
1129
1130
+ if self ._library_file_cache is None :
1131
+ self ._library_file_cache = list (os .walk (self .library_dir ))
1132
+
1127
1133
# for file in self.missing_files:
1128
1134
path = Path (file )
1129
- for root , dirs , files in os . walk ( self .library_dir ) :
1135
+ for root , dirs , files in self ._library_file_cache :
1130
1136
for f in files :
1131
1137
# print(f'{tail} --- {f}')
1132
1138
if path .name == f and "$recycle.bin" not in str (root ).lower ():
You can’t perform that action at this time.
0 commit comments