|
@@ -380,9 +380,7 @@
|
|
|
{
|
|
|
// BACKGROND & FOREGROUND
|
|
|
|
|
|
- //[app performSelectorOnMainThread:@selector(loadAutomaticUploadForSelector:) withObject:selectorUploadAutomaticAll waitUntilDone:NO];
|
|
|
- [app performSelectorOnMainThread:@selector(loadAutomaticUploadForSelector:) withObject:selectorUploadAutomatic waitUntilDone:NO];
|
|
|
-
|
|
|
+ [app performSelectorOnMainThread:@selector(loadAutomaticUpload) withObject:nil waitUntilDone:NO];
|
|
|
|
|
|
// ONLY BACKGROUND
|
|
|
|
|
@@ -1209,29 +1207,12 @@
|
|
|
return metadatasNet;
|
|
|
}
|
|
|
|
|
|
-- (NSMutableArray *)verifyExistsInQueuesUploadSelector:(NSString *)selector
|
|
|
+- (void)loadAutomaticUpload
|
|
|
{
|
|
|
- NSMutableArray *metadatasNet = [[NSMutableArray alloc] init];
|
|
|
-
|
|
|
- for (OCnetworking *operation in [self.netQueueUpload operations])
|
|
|
- if ([operation.metadataNet.selector isEqualToString:selector])
|
|
|
- [metadatasNet addObject:[operation.metadataNet copy]];
|
|
|
-
|
|
|
- for (OCnetworking *operation in [self.netQueueUploadWWan operations])
|
|
|
- if ([operation.metadataNet.selector isEqualToString:selector])
|
|
|
- [metadatasNet addObject:[operation.metadataNet copy]];
|
|
|
-
|
|
|
- return metadatasNet;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)loadAutomaticUploadForSelector:(NSString *)selector
|
|
|
-{
|
|
|
- // Only one
|
|
|
- if ([[self verifyExistsInQueuesUploadSelector:selector] count] > 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ int counter;
|
|
|
|
|
|
// verify Lock pending
|
|
|
+ /*
|
|
|
NSArray *UploadAutomaticInQueue = [self verifyExistsInQueuesUploadSelector:selectorUploadAutomatic];
|
|
|
NSArray *UploadAutomaticAllInQueue = [self verifyExistsInQueuesUploadSelector:selectorUploadAutomaticAll];
|
|
|
NSMutableArray *UploadInQueue = [NSMutableArray new];
|
|
@@ -1252,26 +1233,18 @@
|
|
|
if (!recordFound)
|
|
|
[CCCoreData unlockTableAutomaticUploadForAccount:_activeAccount assetLocalIdentifier:tableAutomaticUpload.assetLocalIdentifier];
|
|
|
}
|
|
|
-
|
|
|
- // Verify num error if selectorUploadAutomaticAll
|
|
|
- if ([selector isEqualToString:selectorUploadAutomaticAll]) {
|
|
|
+ */
|
|
|
|
|
|
- NSUInteger count = [TableMetadata MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", app.activeAccount, selectorUploadAutomaticAll,k_taskIdentifierError, k_taskIdentifierError]];
|
|
|
-
|
|
|
- if (count >= 10) {
|
|
|
-
|
|
|
- [app messageNotification:@"_error_" description:@"_too_errors_automatic_all_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ // ------------------------- <selectorUploadAutomatic> -------------------------
|
|
|
+ counter = 0;
|
|
|
+ do {
|
|
|
|
|
|
- // Get Record on Table Automatic Upload
|
|
|
- CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector];
|
|
|
+ // Get Record on Table Automatic Upload
|
|
|
+ CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selectorUploadAutomatic];
|
|
|
+ if (!metadataNet)
|
|
|
+ break;
|
|
|
|
|
|
- // For UploadAutomatic create the folder for Photos & if request the subfolders
|
|
|
- if ([selector isEqualToString:selectorUploadAutomatic] && metadataNet) {
|
|
|
-
|
|
|
+ // For UploadAutomatic create the folder for Photos & if request the subfolders
|
|
|
NSString *folderPhotos = [CCCoreData getCameraUploadFolderNamePathActiveAccount:app.activeAccount activeUrl:app.activeUrl];
|
|
|
BOOL useSubFolder = [CCCoreData getCameraUploadCreateSubfolderActiveAccount:app.activeAccount];
|
|
|
|
|
@@ -1279,27 +1252,74 @@
|
|
|
|
|
|
if (!result.count) {
|
|
|
|
|
|
- [CCCoreData addActivityClient:metadataNet.fileName fileID:metadataNet.assetLocalIdentifier action:k_activityDebugActionUpload selector:selector note:@"Internal error image/video not found [0]" type:k_activityTypeFailure verbose:k_activityVerboseHigh account:_activeAccount activeUrl:_activeUrl];
|
|
|
+ [CCCoreData addActivityClient:metadataNet.fileName fileID:metadataNet.assetLocalIdentifier action:k_activityDebugActionUpload selector:selectorUploadAutomatic note:@"Internal error image/video not found [0]" type:k_activityTypeFailure verbose:k_activityVerboseHigh account:_activeAccount activeUrl:_activeUrl];
|
|
|
|
|
|
[CCCoreData deleteTableAutomaticUploadForAccount:_activeAccount assetLocalIdentifier:metadataNet.assetLocalIdentifier];
|
|
|
|
|
|
[self updateApplicationIconBadgeNumber];
|
|
|
|
|
|
- return;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
if(![self createFolderSubFolderAutomaticUploadFolderPhotos:folderPhotos useSubFolder:useSubFolder assets:[[NSArray alloc] initWithObjects:result[0], nil] selector:selectorUploadAutomatic]) {
|
|
|
|
|
|
[CCCoreData unlockTableAutomaticUploadForAccount:_activeAccount assetLocalIdentifier:metadataNet.assetLocalIdentifier];
|
|
|
|
|
|
- return;
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
+ [[CCNetworking sharedNetworking] uploadFileFromAssetLocalIdentifier:metadataNet.assetLocalIdentifier fileName:metadataNet.fileName serverUrl:metadataNet.serverUrl cryptated:metadataNet.cryptated session:metadataNet.session taskStatus:metadataNet.taskStatus selector:metadataNet.selector selectorPost:metadataNet.selectorPost errorCode:metadataNet.errorCode delegate:app.activeMain];
|
|
|
+
|
|
|
+ counter++;
|
|
|
+
|
|
|
+ } while (counter < k_maxSelectorUploadAutomatic);
|
|
|
+
|
|
|
+ // ------------------------- <selectorUploadAutomaticAll> -------------------------
|
|
|
+
|
|
|
+ // Only one for selectorUploadAutomaticAll
|
|
|
+ /*
|
|
|
+ if ([[self verifyExistsInQueuesUploadSelector:selectorUploadAutomaticAll] count] > k_maxSelectorUploadAutomaticAll) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
- if (metadataNet) {
|
|
|
+ // Verify num error
|
|
|
+ NSUInteger count = [TableMetadata MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", app.activeAccount, selectorUploadAutomaticAll,k_taskIdentifierError, k_taskIdentifierError]];
|
|
|
+
|
|
|
+ if (count >= 10) {
|
|
|
|
|
|
- [[CCNetworking sharedNetworking] uploadFileFromAssetLocalIdentifier:metadataNet.assetLocalIdentifier fileName:metadataNet.fileName serverUrl:metadataNet.serverUrl cryptated:metadataNet.cryptated session:metadataNet.session taskStatus:metadataNet.taskStatus selector:metadataNet.selector selectorPost:metadataNet.selectorPost errorCode:metadataNet.errorCode delegate:app.activeMain];
|
|
|
+ [app messageNotification:@"_error_" description:@"_too_errors_automatic_all_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
|
|
|
+
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ counter = 0;
|
|
|
+ do {
|
|
|
+
|
|
|
+ // Get Record on Table Automatic Upload
|
|
|
+ CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selectorUploadAutomaticAll];
|
|
|
+ if (!metadataNet)
|
|
|
+ break;
|
|
|
+
|
|
|
+ PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:@[metadataNet.assetLocalIdentifier] options:nil];
|
|
|
+
|
|
|
+ if (!result.count) {
|
|
|
+
|
|
|
+ [CCCoreData addActivityClient:metadataNet.fileName fileID:metadataNet.assetLocalIdentifier action:k_activityDebugActionUpload selector:selectorUploadAutomatic note:@"Internal error image/video not found [0]" type:k_activityTypeFailure verbose:k_activityVerboseHigh account:_activeAccount activeUrl:_activeUrl];
|
|
|
+
|
|
|
+ [CCCoreData deleteTableAutomaticUploadForAccount:_activeAccount assetLocalIdentifier:metadataNet.assetLocalIdentifier];
|
|
|
+
|
|
|
+ [self updateApplicationIconBadgeNumber];
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ [[CCNetworking sharedNetworking] uploadFileFromAssetLocalIdentifier:metadataNet.assetLocalIdentifier fileName:metadataNet.fileName serverUrl:metadataNet.serverUrl cryptated:metadataNet.cryptated session:metadataNet.session taskStatus:metadataNet.taskStatus selector:metadataNet.selector selectorPost:metadataNet.selectorPost errorCode:metadataNet.errorCode delegate:app.activeMain];
|
|
|
+
|
|
|
+ counter++;
|
|
|
+
|
|
|
+ } while (counter < k_maxSelectorUploadAutomaticAll);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)verifyDownloadUploadInProgress
|