Browse Source

fix (194)

Marino Faggiana 7 years ago
parent
commit
e65f8363b6
1 changed files with 14 additions and 8 deletions
  1. 14 8
      iOSClient/Main/CCMain.m

+ 14 - 8
iOSClient/Main/CCMain.m

@@ -3878,19 +3878,25 @@
             NSData *dataFileID = [dic objectForKey: k_metadataKeyedUnarchiver];
             NSString *fileID = [NSKeyedUnarchiver unarchiveObjectWithData:dataFileID];
 
-            tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
+            if (fileID) {
+            
+                tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
             
-            if (metadata) {
+                if (metadata) {
             
-                tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", metadata.account]];
+                    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", metadata.account]];
 
-                if (account) {
+                    if (account) {
                 
-                    NSString *directoryUser = [CCUtility getDirectoryActiveUser:account.user activeUrl:account.url];
+                        NSString *directoryUser = [CCUtility getDirectoryActiveUser:account.user activeUrl:account.url];
             
-                    if (directoryUser) {
-                        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", directoryUser, fileID]]) {
-                            isValid = YES;
+                        if (directoryUser) {
+                            if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", directoryUser, fileID]]) {
+                                isValid = YES;
+                            } else {
+                                isValid = NO;
+                                break;
+                            }
                         } else {
                             isValid = NO;
                             break;