|
@@ -543,36 +543,33 @@
|
|
|
- (void)loadAutoUpload:(NSNumber *)maxConcurrent
|
|
|
{
|
|
|
CCMetadataNet *metadataNet;
|
|
|
- NSInteger counterUpload = 0;
|
|
|
- NSInteger maxConcurrentOperationDownloadUpload = [maxConcurrent integerValue];
|
|
|
+ PHFetchResult *result;
|
|
|
|
|
|
- NSArray *uploadInQueue = [[NCManageDatabase sharedInstance] getTableMetadataUpload];
|
|
|
+ NSInteger maxConcurrentUpload = [maxConcurrent integerValue];
|
|
|
+ NSInteger counterUpload = [app getNumberUploadInQueues] + [app getNumberUploadInQueuesWWan] + [[[NCManageDatabase sharedInstance] getLockAutoUpload] count];
|
|
|
|
|
|
- NSArray *recordAutomaticUploadInLock = [[NCManageDatabase sharedInstance] getLockAutoUpload];
|
|
|
+ // ------------------------- <selector Auto Upload> -------------------------
|
|
|
|
|
|
- for (tableAutoUpload *tableAutoUpload in recordAutomaticUploadInLock) {
|
|
|
+ while (counterUpload < maxConcurrentUpload) {
|
|
|
|
|
|
- BOOL recordFound = NO;
|
|
|
+ metadataNet = [[NCManageDatabase sharedInstance] getAutoUploadWithSelector:selectorUploadAutoUpload];
|
|
|
+ if (metadataNet)
|
|
|
+ result = [PHAsset fetchAssetsWithLocalIdentifiers:@[metadataNet.assetLocalIdentifier] options:nil];
|
|
|
+ else
|
|
|
+ break;
|
|
|
|
|
|
- for (CCMetadataNet *metadataNet in uploadInQueue) {
|
|
|
- if (metadataNet.assetLocalIdentifier == tableAutoUpload.assetLocalIdentifier)
|
|
|
- recordFound = YES;
|
|
|
+ if (result.count > 0) {
|
|
|
+
|
|
|
+ [[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];
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ [[NCManageDatabase sharedInstance] addActivityClient:metadataNet.fileName fileID:metadataNet.assetLocalIdentifier action:k_activityDebugActionUpload selector:selectorUploadAutoUploadAll note:@"Internal error image/video not found [0]" type:k_activityTypeFailure verbose:k_activityVerboseHigh activeUrl:app.activeUrl];
|
|
|
+
|
|
|
+ [[NCManageDatabase sharedInstance] deleteAutoUploadWithAssetLocalIdentifier:metadataNet.assetLocalIdentifier];
|
|
|
}
|
|
|
|
|
|
- if (!recordFound)
|
|
|
- [[NCManageDatabase sharedInstance] unlockAutoUploadWithAssetLocalIdentifier:tableAutoUpload.assetLocalIdentifier];
|
|
|
- }
|
|
|
-
|
|
|
- // ------------------------- <selector Auto Upload> -------------------------
|
|
|
-
|
|
|
- metadataNet = [[NCManageDatabase sharedInstance] getAutoUploadWithSelector:selectorUploadAutoUpload];
|
|
|
- counterUpload = [app getNumberUploadInQueues] + [app getNumberUploadInQueuesWWan];
|
|
|
- while (metadataNet && counterUpload < maxConcurrentOperationDownloadUpload) {
|
|
|
-
|
|
|
- [[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];
|
|
|
-
|
|
|
- metadataNet = [[NCManageDatabase sharedInstance] getAutoUploadWithSelector:selectorUploadAutoUpload];
|
|
|
- counterUpload++;
|
|
|
+ counterUpload = [app getNumberUploadInQueues] + [app getNumberUploadInQueuesWWan] + [[[NCManageDatabase sharedInstance] getLockAutoUpload] count];
|
|
|
}
|
|
|
|
|
|
// ------------------------- <selector Auto Upload All> ----------------------
|
|
@@ -588,18 +585,18 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- metadataNet = [[NCManageDatabase sharedInstance] getAutoUploadWithSelector:selectorUploadAutoUploadAll];
|
|
|
- counterUpload = [app getNumberUploadInQueues] + [app getNumberUploadInQueuesWWan];
|
|
|
- while (metadataNet && counterUpload < maxConcurrentOperationDownloadUpload) {
|
|
|
-
|
|
|
- PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:@[metadataNet.assetLocalIdentifier] options:nil];
|
|
|
+ while (counterUpload < maxConcurrentUpload) {
|
|
|
|
|
|
+ metadataNet = [[NCManageDatabase sharedInstance] getAutoUploadWithSelector:selectorUploadAutoUploadAll];
|
|
|
+ if (metadataNet)
|
|
|
+ result = [PHAsset fetchAssetsWithLocalIdentifiers:@[metadataNet.assetLocalIdentifier] options:nil];
|
|
|
+ else
|
|
|
+ break;
|
|
|
+
|
|
|
if (result.count > 0) {
|
|
|
|
|
|
[[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];
|
|
|
|
|
|
- counterUpload++;
|
|
|
-
|
|
|
} else {
|
|
|
|
|
|
[[NCManageDatabase sharedInstance] addActivityClient:metadataNet.fileName fileID:metadataNet.assetLocalIdentifier action:k_activityDebugActionUpload selector:selectorUploadAutoUploadAll note:@"Internal error image/video not found [0]" type:k_activityTypeFailure verbose:k_activityVerboseHigh activeUrl:app.activeUrl];
|
|
@@ -607,7 +604,7 @@
|
|
|
[[NCManageDatabase sharedInstance] deleteAutoUploadWithAssetLocalIdentifier:metadataNet.assetLocalIdentifier];
|
|
|
}
|
|
|
|
|
|
- metadataNet = [[NCManageDatabase sharedInstance] getAutoUploadWithSelector:selectorUploadAutoUploadAll];
|
|
|
+ counterUpload = [app getNumberUploadInQueues] + [app getNumberUploadInQueuesWWan] + [[[NCManageDatabase sharedInstance] getLockAutoUpload] count];
|
|
|
}
|
|
|
}
|
|
|
|