tingxins / SakuraKit

🤡SakuraKit, a lightweight and powerful library for application to switching themes or skins.
https://tingxins.com/2017/08/ios-theme-skin-resolution/
MIT License
691 stars 116 forks source link

__MACOSX 错处。 #14

Open ShouBinCheng opened 5 years ago

ShouBinCheng commented 5 years ago

解压产生__MACOSX文件夹,当资质文件没首字母小于M时下载后移除文件操作错误。 应修改为:

+ (void)formatSakuraPath:(NSString *)sakuraPath cleanCachePath:(NSString * _Nullable)cachePath {
    if (!sakuraPath || !sakuraPath.length) return;
    if (cachePath) {
        [TXSakuraManager tx_clearSakuraCacheWithPath:cachePath];
    }
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSError *error = nil;
   //修改处 start
    NSMutableArray *folders = [fileManager contentsOfDirectoryAtPath:sakuraPath error:&error].mutableCopy;
    if ([folders containsObject:@"__MACOSX"]) {
        [folders removeObject:@"__MACOSX"];
    }
    //end
    NSString *folderName = sakuraPath.lastPathComponent;
    NSString *tempName = [folders.lastObject stringByAppendingString:folderName];
    NSString *moveItemPath = [sakuraPath stringByAppendingPathComponent:folders.lastObject];
    NSString *tempItemPath = [[sakuraPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:tempName];
    [fileManager moveItemAtPath:moveItemPath toPath:tempItemPath error:&error];
    [fileManager removeItemAtPath:sakuraPath error:&error];
    [fileManager moveItemAtPath:tempItemPath toPath:sakuraPath error:&error];
#ifdef DEBUG
    NSLog(@"folders:%@", folders);
    NSLog(@"sakuraPath:%@--%@",sakuraPath, error);
#endif
}