Explorar el Código

fix thread realm E2EE + fix rename E2EE

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana hace 3 años
padre
commit
ae8b2ad5ae

+ 3 - 3
iOSClient/Data/NCManageDatabase.swift

@@ -2214,15 +2214,15 @@ class NCManageDatabase: NSObject {
                         // update
                         if result.status == NCGlobal.shared.metadataStatusNormal && (result.etag != metadata.etag || result.fileNameView != metadata.fileNameView || result.date != metadata.date || result.permissions != metadata.permissions || result.hasPreview != metadata.hasPreview || result.note != metadata.note) {
                             ocIdsUdate.append(metadata.ocId)
-                            realm.add(metadata, update: .all)
+                            realm.add(tableMetadata.init(value: metadata), update: .all)
                         } else if result.status == NCGlobal.shared.metadataStatusNormal && addCompareLivePhoto && result.livePhoto != metadata.livePhoto {
                             ocIdsUdate.append(metadata.ocId)
-                            realm.add(metadata, update: .all)
+                            realm.add(tableMetadata.init(value: metadata), update: .all)
                         }
                     } else {
                         // new
                         ocIdsUdate.append(metadata.ocId)
-                        realm.add(metadata, update: .all)
+                        realm.add(tableMetadata.init(value: metadata), update: .all)
                     }
                     
                     if metadata.directory && !ocIdsUdate.contains(metadata.ocId) {

+ 1 - 0
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1022,6 +1022,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                                 if metadataFolder.e2eEncrypted && CCUtility.isEnd(toEndEnabled: self.appDelegate.account) {
                                                                         
                                     NCCommunication.shared.getE2EEMetadata(fileId: metadataFolder.ocId, e2eToken: nil) { (account, e2eMetadata, errorCode, errorDescription) in
+                                        
                                         if errorCode == 0 && e2eMetadata != nil {
                                             
                                             if !NCEndToEndMetadata.shared.decoderMetadata(e2eMetadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: self.serverUrl, account: account, urlBase: self.appDelegate.urlBase) {

+ 5 - 5
iOSClient/Rename file/NCRenameFile.swift

@@ -66,11 +66,11 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
                 titleLabel.text = NSLocalizedString("_rename_file_", comment: "")
             }
             
-            fileNameWithoutExt.text = metadata.fileNameWithoutExt
+            fileNameWithoutExt.text = (metadata.fileNameView as NSString).deletingPathExtension
             fileNameWithoutExt.delegate = self
             fileNameWithoutExt.becomeFirstResponder()
             
-            ext.text = metadata.ext
+            ext.text = (metadata.fileNameView as NSString).pathExtension
             ext.delegate = self
             if disableChangeExt {
                 ext.isEnabled = false
@@ -162,7 +162,7 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
         if let metadata = self.metadata {
         
             if fileNameWithoutExt.text == nil || fileNameWithoutExt.text?.count == 0 {
-                self.fileNameWithoutExt.text = metadata.fileNameWithoutExt
+                self.fileNameWithoutExt.text = (metadata.fileNameView as NSString).deletingPathExtension
                 return
             } else {
                 fileNameWithoutExtNew = fileNameWithoutExt.text!
@@ -176,7 +176,7 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
             } else {
                 
                 if ext.text == nil || ext.text?.count == 0 {
-                    self.ext.text = metadata.ext
+                    self.ext.text = (metadata.fileNameView as NSString).pathExtension
                     return
                 } else {
                     extNew = ext.text!
@@ -196,7 +196,7 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
                     
                     title = NSLocalizedString("_keep_", comment: "") + " ." + metadata.ext
                     alertController.addAction(UIAlertAction(title: title, style: .default, handler: { action in
-                        self.ext.text = metadata.ext
+                        self.ext.text = (metadata.fileNameView as NSString).pathExtension
                     }))
                     
                     self.present(alertController, animated: true)

+ 1 - 0
iOSClient/Security/NCEndToEndMetadata.swift

@@ -217,6 +217,7 @@ class NCEndToEndMetadata : NSObject  {
                         
                         // Update metadata on tableMetadata
                         metadata.fileNameView = encryptedFileAttributes.filename
+                        metadata.fileNameWithoutExt = (encryptedFileAttributes.filename as NSString).deletingPathExtension
                         
                         let results = NCCommunicationCommon.shared.getInternalType(fileName: encryptedFileAttributes.filename, mimeType: metadata.contentType, directory: metadata.directory)