File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed
Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -441,23 +441,26 @@ - (void)backgroundCleanDisk {
441441}
442442
443443- (NSUInteger )getSize {
444- NSUInteger size = 0 ;
445- NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager ] enumeratorAtPath: self .diskCachePath];
446- for (NSString *fileName in fileEnumerator) {
447- NSString *filePath = [self .diskCachePath stringByAppendingPathComponent: fileName];
448- NSDictionary *attrs = [[NSFileManager defaultManager ] attributesOfItemAtPath: filePath error: nil ];
449- size += [attrs fileSize ];
450- }
444+ __block NSUInteger size = 0 ;
445+ dispatch_sync (self.ioQueue , ^{
446+ NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath: self .diskCachePath];
447+ for (NSString *fileName in fileEnumerator) {
448+ NSString *filePath = [self .diskCachePath stringByAppendingPathComponent: fileName];
449+ NSDictionary *attrs = [[NSFileManager defaultManager ] attributesOfItemAtPath: filePath error: nil ];
450+ size += [attrs fileSize ];
451+ }
452+ });
451453 return size;
452454}
453455
454456- (int )getDiskCount {
455- int count = 0 ;
456- NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager ] enumeratorAtPath: self .diskCachePath];
457- for (__unused NSString *fileName in fileEnumerator) {
458- count += 1 ;
459- }
460-
457+ __block int count = 0 ;
458+ dispatch_sync (self.ioQueue , ^{
459+ NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath: self .diskCachePath];
460+ for (__unused NSString *fileName in fileEnumerator) {
461+ count += 1 ;
462+ }
463+ });
461464 return count;
462465}
463466
You can’t perform that action at this time.
0 commit comments