|
|
@@ -8,12 +8,12 @@
|
|
|
|
|
|
#import "RAOfflineHandler.h"
|
|
|
#import "NetworkUtils.h"
|
|
|
-#import "ZipArchive.h"
|
|
|
#import "RADetailBaseModel.h"
|
|
|
#import "RAHomeOrderModel.h"
|
|
|
#import "RADetailActionModel.h"
|
|
|
#import "AppDelegate.h"
|
|
|
#import "RAEditImageBaseModel.h"
|
|
|
+#import "RAArchiver.h"
|
|
|
|
|
|
#define Lock() dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER)
|
|
|
#define Unlock() dispatch_semaphore_signal(_lock)
|
|
|
@@ -405,14 +405,7 @@ static dispatch_semaphore_t _lock;
|
|
|
*/
|
|
|
- (BOOL)_unzipOfflineZip:(NSString *)path toDir:(NSString *)to {
|
|
|
|
|
|
- ZipArchive *zip = [[ZipArchive alloc] init];
|
|
|
- BOOL zipRes = [zip UnzipOpenFile:path Password:self.zipPassword];
|
|
|
- if (zipRes) {
|
|
|
- zipRes = [zip UnzipFileTo:to overWrite:YES];
|
|
|
- }
|
|
|
- [zip UnzipCloseFile];
|
|
|
-
|
|
|
- return zipRes;
|
|
|
+ return [RAArchiver ra_unzipOfflineZip:path toDir:to withPassword:self.zipPassword];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -422,21 +415,12 @@ static dispatch_semaphore_t _lock;
|
|
|
*/
|
|
|
- (NSString *)_zipDir:(NSString *)dir {
|
|
|
|
|
|
- NSString *name = [[dir lastPathComponent] stringByAppendingString:@".zip"];
|
|
|
- NSString *zipFile = [[dir stringByDeletingLastPathComponent] stringByAppendingPathComponent:name];
|
|
|
+ NSString *zipFile = [dir stringByAppendingPathExtension:@"zip"];
|
|
|
|
|
|
- ZipArchive *zip = [[ZipArchive alloc] init];
|
|
|
- [zip CreateZipFile2:zipFile Password:self.zipPassword];
|
|
|
-
|
|
|
- NSFileManager *fm = [NSFileManager defaultManager];
|
|
|
- NSArray *list = [fm contentsOfDirectoryAtPath:dir error:nil];
|
|
|
- for (NSString *imgPath in list) {
|
|
|
- [zip addFileToZip:imgPath newname:imgPath.lastPathComponent];
|
|
|
+ if ([RAArchiver ra_zipFile:dir withPassword:self.zipPassword]) {
|
|
|
+ return zipFile;
|
|
|
}
|
|
|
-
|
|
|
- [zip CloseZipFile2];
|
|
|
-
|
|
|
- return zipFile;
|
|
|
+ return nil;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -457,10 +441,15 @@ static dispatch_semaphore_t _lock;
|
|
|
|
|
|
// 一层层解开,获取到目标值后作出修改,然后反向一层层的套回去
|
|
|
NSMutableArray<NSDictionary *> *sections = [[detail objectForKey:@"sections"] mutableCopy];
|
|
|
+
|
|
|
+ NSMutableIndexSet *rmSectionArr = [NSMutableIndexSet indexSet];
|
|
|
+
|
|
|
[sections enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
|
NSMutableDictionary *section = [obj mutableCopy];
|
|
|
NSMutableArray<NSDictionary *> *values = [[section objectForKey:@"values"] mutableCopy];
|
|
|
+
|
|
|
+ NSMutableIndexSet *rmValueArr = [NSMutableIndexSet indexSet];
|
|
|
[values enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
|
int type = [[obj objectForKey:@"type"] intValue];
|
|
|
@@ -477,16 +466,33 @@ static dispatch_semaphore_t _lock;
|
|
|
|
|
|
}];
|
|
|
[actions removeObjectsInArray:rmArr];
|
|
|
+
|
|
|
+ if (actions.count == 0) {
|
|
|
+ [rmValueArr addIndex:idx];
|
|
|
+ }
|
|
|
+
|
|
|
[mObj setObject:actions forKey:@"actions"];
|
|
|
[values replaceObjectAtIndex:idx withObject:mObj];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}];
|
|
|
+
|
|
|
+ if (rmValueArr.count > 0) {
|
|
|
+ [values removeObjectsAtIndexes:rmValueArr];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (values.count == 0) {
|
|
|
+ [rmSectionArr addIndex:idx];
|
|
|
+ }
|
|
|
+
|
|
|
[section setObject:values forKey:@"values"];
|
|
|
[sections replaceObjectAtIndex:idx withObject:section];
|
|
|
}];
|
|
|
+
|
|
|
+ if (rmSectionArr.count > 0) {
|
|
|
+ [sections removeObjectsAtIndexes:rmSectionArr];
|
|
|
+ }
|
|
|
+
|
|
|
[detail setObject:sections forKey:@"sections"];
|
|
|
|
|
|
return detail;
|