فهرست منبع

change primary Key on tableE2eEncryption

Marino Faggiana 7 سال پیش
والد
کامیت
7605d07658

+ 2 - 1
iOSClient/Database/NCDatabase.swift

@@ -120,6 +120,7 @@ class tableE2eEncryption: Object {
     @objc dynamic var authenticationTag = ""
     @objc dynamic var fileName = ""
     @objc dynamic var fileNameIdentifier = ""
+    @objc dynamic var fileNamePath = ""
     @objc dynamic var key = ""
     @objc dynamic var initializationVector = ""
     @objc dynamic var mimeType = ""
@@ -127,7 +128,7 @@ class tableE2eEncryption: Object {
     @objc dynamic var version: Int = 1
     
     override static func primaryKey() -> String {
-        return "fileNameIdentifier"
+        return "fileNamePath"
     }
 }
 

+ 1 - 2
iOSClient/Database/NCManageDatabase.swift

@@ -61,8 +61,7 @@ class NCManageDatabase: NSObject {
             
             // 10 : Version 2.18.0
             // 11 : Add object tableE2eEncryption
-            // 12 : Change primary key of tableE2eEncryption for fileNameIdentifier, remove filed metadataKey, add tokenLock and encrypted on Table Directory
-            //    : add fileNameView on Metadata
+            // 12 : Change primary key of tableE2eEncryption
             
             migrationBlock: { migration, oldSchemaVersion in
                 // We haven’t migrated anything yet, so oldSchemaVersion == 0

+ 1 - 0
iOSClient/Networking/CCNetworking.m

@@ -1597,6 +1597,7 @@
         addObject.authenticationTag = authenticationTag;
         addObject.fileName = fileName;
         addObject.fileNameIdentifier = fileNameIdentifier;
+        addObject.fileNamePath = [CCUtility returnFileNamePathFromFileName:fileName serverUrl:serverUrl activeUrl:_activeUrl];
         addObject.key = key;
         addObject.initializationVector = initializationVector;
         

+ 4 - 1
iOSClient/Security/NCEndToEndMetadata.swift

@@ -109,7 +109,7 @@ class NCEndToEndMetadata : NSObject  {
         }
     }
     
-    @objc func decoderMetadata(_ e2eMetaDataJSON: String, privateKey: String, serverUrl: String, account: String) -> Bool {
+    @objc func decoderMetadata(_ e2eMetaDataJSON: String, privateKey: String, serverUrl: String, account: String, url: String) -> Bool {
         
         let jsonDecoder = JSONDecoder.init()
         let data = e2eMetaDataJSON.data(using: .utf8)
@@ -163,12 +163,15 @@ class NCEndToEndMetadata : NSObject  {
                     object.authenticationTag = elementOfFile.authenticationTag
                     object.fileName = decode.filename
                     object.fileNameIdentifier = fileNameIdentifier
+                    object.fileNamePath = CCUtility.returnFileNamePath(fromFileName: decode.filename, serverUrl: serverUrl, activeUrl: url)
                     object.key = decode.key
                     object.initializationVector = elementOfFile.initializationVector
                     object.mimeType = decode.mimetype
                     object.serverUrl = serverUrl
                     object.version = decode.version
                     
+                    // [CCUtility returnFileNamePathFromFileName:fileName serverUrl:serverUrl activeUrl:_activeUrl];
+                    
                     // Write file parameter for decrypted on DB
                     if NCManageDatabase.sharedInstance.addE2eEncryption(object) == false {
                         return false

+ 1 - 1
iOSClient/Security/NCEntoToEndInterface.swift

@@ -402,7 +402,7 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
         let serverUrl = metadataNet.serverUrl + "/" + metadataNet.fileName
         
         // Decode metadata JSON
-        if NCEndToEndMetadata.sharedInstance.decoderMetadata(metadataNet.encryptedMetadata, privateKey: privateKey, serverUrl: serverUrl, account: appDelegate.activeAccount) == false {
+        if NCEndToEndMetadata.sharedInstance.decoderMetadata(metadataNet.encryptedMetadata, privateKey: privateKey, serverUrl: serverUrl, account: appDelegate.activeAccount, url: appDelegate.activeUrl) == false {
         
             appDelegate.messageNotification("E2E decode metadata", description: "Serious internal error in decoding metadata", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: 0)
             return