|
@@ -30,23 +30,28 @@ static CloudStorageDB *cloudStorageDB;
|
|
|
return cloudStorageDB;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- (instancetype)init
|
|
|
{
|
|
|
if (self = [super init]) {
|
|
|
|
|
|
+ NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
|
|
+ // app名称
|
|
|
+ NSString *app_Name = [infoDictionary objectForKey:@"CFBundleName"];
|
|
|
|
|
|
- NSString *localPath = [NSPersistentStore MR_defaultLocalStoreUrl].absoluteString.stringByDeletingLastPathComponent;
|
|
|
-
|
|
|
+ NSString *appSuportPath = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
|
|
+ BOOL isDirectory_appSuportPath = YES;
|
|
|
+ NSError *error;
|
|
|
+ NSString *localPath = [appSuportPath stringByAppendingPathComponent:app_Name];
|
|
|
+ BOOL existsDirectory = [[NSFileManager defaultManager]fileExistsAtPath:localPath isDirectory:&isDirectory_appSuportPath];
|
|
|
+ if (!existsDirectory) {
|
|
|
+ [[NSFileManager defaultManager]createDirectoryAtPath:localPath withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
+
|
|
|
+ }
|
|
|
NSString *path = [NSString stringWithFormat:@"%@/%@_cloudStorageDisk.sqlite",localPath,Login_Name];
|
|
|
- NSFileManager *filemanager = [NSFileManager defaultManager];
|
|
|
+ //BOOL existsDBfile = [[NSFileManager defaultManager]fileExistsAtPath:appSuportPath isDirectory:(BOOL*)NO];
|
|
|
|
|
|
- NSString *libraryPathstr = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
|
|
|
- NSString *applicationsupportdir = [libraryPathstr stringByAppendingString:@"/Application Support"];
|
|
|
+
|
|
|
|
|
|
- NSError *error;
|
|
|
- BOOL resultlocalpath = [filemanager createDirectoryAtPath:applicationsupportdir withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
- NSString *dbpath =
|
|
|
//创建表
|
|
|
self.dbOperation = [DBOperation dbOperationWithPath:path];
|
|
|
|
|
@@ -55,11 +60,40 @@ static CloudStorageDB *cloudStorageDB;
|
|
|
[self.dbOperation creatDBWithTableName:downTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
|
|
|
|
|
|
[self.dbOperation creatDBWithTableName:upTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return self;
|
|
|
}
|
|
|
+//- (instancetype)init
|
|
|
+//{
|
|
|
+// if (self = [super init]) {
|
|
|
+//
|
|
|
+//
|
|
|
+// NSString *localPath = [NSPersistentStore MR_defaultLocalStoreUrl].absoluteString.stringByDeletingLastPathComponent;
|
|
|
+//
|
|
|
+// NSString *path = [NSString stringWithFormat:@"%@/%@_cloudStorageDisk.sqlite",localPath,Login_Name];
|
|
|
+// NSFileManager *filemanager = [NSFileManager defaultManager];
|
|
|
+//
|
|
|
+// NSString *libraryPathstr = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
|
|
|
+// NSString *applicationsupportdir = [libraryPathstr stringByAppendingString:@"/Application Support"];
|
|
|
+//
|
|
|
+// NSError *error;
|
|
|
+// BOOL resultlocalpath = [filemanager createDirectoryAtPath:applicationsupportdir withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
+// NSString *dbpath =
|
|
|
+// //创建表
|
|
|
+// self.dbOperation = [DBOperation dbOperationWithPath:path];
|
|
|
+//
|
|
|
+// [self.dbOperation creatDBWithTableName:cacheFileList dbModelClass:[CSFileModel class] Path:path autoUpgrade:YES uniqueCloumName:@"sid"];
|
|
|
+//
|
|
|
+// [self.dbOperation creatDBWithTableName:downTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
|
|
|
+//
|
|
|
+// [self.dbOperation creatDBWithTableName:upTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// return self;
|
|
|
+//}
|
|
|
|
|
|
//建立索引
|
|
|
- (void)createIndexForTableName:(NSString *)name indexCloums:(NSArray<NSArray*> *)indexCloums
|