Browse Source

remove isExecuting

Marino Faggiana 8 years ago
parent
commit
f857f75548

+ 1 - 1
Share Ext/InfoNextcloud.plist

@@ -21,7 +21,7 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>00001</string>
+	<string>00002</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 2 - 2
iOSClient/AppDelegate.m

@@ -1071,9 +1071,9 @@
     
     // Add Network queue
     
-    NSArray *metadatasNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector numRecords:maxConcurrentAutomaticUpload context:nil];
+    CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector context:nil];
     
-    for (CCMetadataNet *metadataNet in metadatasNet) {
+    if (metadataNet) {
         
         NSOperationQueue *queue;
         

+ 0 - 2
iOSClient/CCGlobal.h

@@ -197,8 +197,6 @@ extern NSString *const BKPasscodeKeychainServiceName;
 #define maxConcurrentOperation 10
 #define maxConcurrentOperationDownloadUpload 10
 
-#define maxConcurrentAutomaticUpload 1
-
 // Error
 #define CCErrorTaskNil -9999
 #define CCErrorTaskDownloadNotFound -9998

+ 1 - 2
iOSClient/FileSystem/CCCoreData.h

@@ -179,9 +179,8 @@
 // ===== Automatic Upload =====
 
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet account:(NSString *)account context:(NSManagedObjectContext *)context;
-+ (NSArray *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context;
++ (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector context:(NSManagedObjectContext *)context;
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector;
-+ (void)setTableAutomaticUploadIfExecutingForAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
 + (void)deleteTableAutomaticUploadForAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
 
 // ===== GPS =====

+ 8 - 34
iOSClient/FileSystem/CCCoreData.m

@@ -1488,7 +1488,6 @@
     record.assetLocalItentifier = metadataNet.assetLocalItentifier;
     record.date = [NSDate date];
     record.fileName = metadataNet.fileName;
-    record.isExecuting = [NSNumber numberWithBool:NO];
     record.selector = metadataNet.selector;
     record.selectorPost = metadataNet.selectorPost;
     record.serverUrl = metadataNet.serverUrl;
@@ -1498,21 +1497,15 @@
     [context MR_saveToPersistentStoreAndWait];
 }
 
-+ (NSArray *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context
++ (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector context:(NSManagedObjectContext *)context
 {
-    if (numRecords == 0)
-        return nil;
-    
-    NSMutableArray *metadatasNet = [[NSMutableArray alloc] init];
-    NSUInteger counter = 0;
-    
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
     
-    NSArray *records = [TableAutomaticUpload MR_findAllWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@) AND (isExecuting == 0)", account, selector]];
+    TableAutomaticUpload *record = [TableAutomaticUpload MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@)", account, selector]];
+    
+    if (record) {
     
-    for (TableAutomaticUpload *record in records) {
-        
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] init];
         
         metadataNet.action = actionUploadAsset;                             // Default
@@ -1525,37 +1518,18 @@
         metadataNet.session = record.session;
         metadataNet.taskStatus = taskStatusResume;                          // Default
         
-        [metadatasNet addObject:metadataNet];
-        
-        if (++counter == numRecords)
-            break;
+        return metadataNet;
     }
     
-    return metadatasNet;
+    return nil;
 }
 
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector
 {
     if (selector)
-        return [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (isExecuting == 0) AND (selector == %@)", account, selector]];
+        return [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@)", account, selector]];
     else
-        return [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (isExecuting == 0)", account]];
-}
-
-+ (void)setTableAutomaticUploadIfExecutingForAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context
-{
-    if (context == nil)
-        context = [NSManagedObjectContext MR_context];
-    
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@) AND (selector == %@)", account, fileName, serverUrl, selector];
-    TableAutomaticUpload *record = [TableAutomaticUpload MR_findFirstWithPredicate:predicate inContext:context];
-    
-    if (record) {
-        
-        record.isExecuting = [NSNumber numberWithBool:YES];
-        
-        [context MR_saveToPersistentStoreAndWait];
-    }
+        return [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", account]];
 }
 
 + (void)deleteTableAutomaticUploadForAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context

+ 0 - 1
iOSClient/FileSystem/TableAutomaticUpload+CoreDataProperties.h

@@ -19,7 +19,6 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nullable, nonatomic, copy) NSString *assetLocalItentifier;
 @property (nullable, nonatomic, copy) NSDate *date;
 @property (nullable, nonatomic, copy) NSString *fileName;
-@property (nullable, nonatomic, copy) NSNumber *isExecuting;
 @property (nullable, nonatomic, copy) NSNumber *priority;
 @property (nullable, nonatomic, copy) NSString *selector;
 @property (nullable, nonatomic, copy) NSString *selectorPost;

+ 0 - 1
iOSClient/FileSystem/TableAutomaticUpload+CoreDataProperties.m

@@ -18,7 +18,6 @@
 @dynamic assetLocalItentifier;
 @dynamic date;
 @dynamic fileName;
-@dynamic isExecuting;
 @dynamic priority;
 @dynamic selector;
 @dynamic selectorPost;

+ 1 - 1
iOSClient/InfoPlist/InfoNextcloud.plist

@@ -69,7 +69,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>00001</string>
+	<string>00002</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<true/>
 	<key>ITSEncryptionExportComplianceCode</key>

+ 2 - 10
iOSClient/Main/CCMain.m

@@ -1395,25 +1395,17 @@
     }
     
     // Automatic upload
-    if([selector isEqualToString:selectorUploadAutomatic] || [selector isEqualToString:selectorUploadAutomaticAll]) {
-        
-        [CCCoreData deleteTableAutomaticUploadForAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
+    if([selector isEqualToString:selectorUploadAutomatic] || [selector isEqualToString:selectorUploadAutomaticAll])
         [app loadTableAutomaticUploadForSelector:selector];
-    }
     
     [self getDataSourceWithReloadTableView:[CCCoreData getDirectoryIDFromServerUrl:serverUrl activeAccount:app.activeAccount] fileID:nil selector:selector];
 }
 
 - (void)uploadFileSuccess:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
 {
-    CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, app.activeAccount] context:nil];
-    
     // Automatic upload
-    if([selector isEqualToString:selectorUploadAutomatic] || [selector isEqualToString:selectorUploadAutomaticAll]) {
-        
-        [CCCoreData deleteTableAutomaticUploadForAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
+    if([selector isEqualToString:selectorUploadAutomatic] || [selector isEqualToString:selectorUploadAutomaticAll])
         [app loadTableAutomaticUploadForSelector:selector];
-    }
     
     if ([selectorPost isEqualToString:selectorReadFolderForced] ) {
             

+ 2 - 2
iOSClient/Networking/CCNetworking.m

@@ -1360,8 +1360,8 @@
 
     // Automatic upload set YES isExecuting
     if([selector isEqualToString:selectorUploadAutomatic] || [selector isEqualToString:selectorUploadAutomaticAll])
-        [CCCoreData setTableAutomaticUploadIfExecutingForAccount:_activeAccount fileName:fileNamePrint serverUrl:serverUrl selector:selector context:_context];
-    
+        [CCCoreData deleteTableAutomaticUploadForAccount:_activeAccount fileName:fileNamePrint serverUrl:serverUrl selector:selector context:_context];
+            
     dispatch_async(dispatch_get_main_queue(), ^{
         
         // refresh main

+ 1 - 2
iOSClient/cryptocloud.xcdatamodeld/cryptocloud 5.xcdatamodel/contents

@@ -32,7 +32,6 @@
         <attribute name="assetLocalItentifier" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="fileName" optional="YES" attributeType="String" syncable="YES"/>
-        <attribute name="isExecuting" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="priority" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="selector" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="selectorPost" optional="YES" attributeType="String" syncable="YES"/>
@@ -131,6 +130,6 @@
         <element name="TableLocalFile" positionX="-5472" positionY="153" width="135" height="225"/>
         <element name="TableMetadata" positionX="-5949" positionY="162" width="162" height="525"/>
         <element name="TableShare" positionX="-5976" positionY="297" width="128" height="135"/>
-        <element name="TableAutomaticUpload" positionX="-5967" positionY="306" width="128" height="195"/>
+        <element name="TableAutomaticUpload" positionX="-5967" positionY="306" width="128" height="180"/>
     </elements>
 </model>