Эх сурвалжийг харах

Fix set filesize in create VoiceMemo

+ some slight refactoring

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 жил өмнө
parent
commit
669ea16af5

+ 7 - 7
iOSClient/AppDelegate.swift

@@ -873,13 +873,13 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
 
 
     func didFinishRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
     func didFinishRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
 
 
-        guard let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() else { return }
-        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
-        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadVoiceNote
-        viewController.setup(serverUrl: appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
-        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+        guard
+            let navigationController = UIStoryboard(name: "NCCreateFormUploadVoiceNote", bundle: nil).instantiateInitialViewController() as? UINavigationController,
+                let viewController = navigationController.topViewController as? NCCreateFormUploadVoiceNote
+        else { return }
+        navigationController.modalPresentationStyle = .formSheet
+        viewController.setup(serverUrl: activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
+        window?.rootViewController?.present(navigationController, animated: true)
     }
     }
 
 
     func didFinishWithoutRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {
     func didFinishWithoutRecording(_ viewController: NCAudioRecorderViewController, fileName: String) {

+ 2 - 3
iOSClient/Main/AudioRecorder/NCAudioRecorderViewController.swift

@@ -188,8 +188,8 @@ open class NCAudioRecorder: NSObject {
 
 
     // MARK: - Initializers
     // MARK: - Initializers
 
 
-    public init(to: String) {
-        url = URL(fileURLWithPath: NCAudioRecorder.directory).appendingPathComponent(to)
+    public init(to fileName: String) {
+        url = URL(fileURLWithPath: NCAudioRecorder.directory).appendingPathComponent(fileName)
         super.init()
         super.init()
 
 
         do {
         do {
@@ -278,7 +278,6 @@ open class NCAudioRecorder: NSObject {
     }
     }
 
 
     fileprivate func stopMetering() {
     fileprivate func stopMetering() {
-
         link?.invalidate()
         link?.invalidate()
         link = nil
         link = nil
     }
     }

+ 1 - 0
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -245,6 +245,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
         metadataForUpload.session = NCNetworking.shared.sessionIdentifierBackground
         metadataForUpload.session = NCNetworking.shared.sessionIdentifierBackground
         metadataForUpload.sessionSelector = NCGlobal.shared.selectorUploadFile
         metadataForUpload.sessionSelector = NCGlobal.shared.selectorUploadFile
         metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
         metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
+        metadataForUpload.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNamePath)
 
 
         if NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileName: fileNameSave) != nil {
         if NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileName: fileNameSave) != nil {
 
 

+ 1 - 2
iOSClient/Utility/CCUtility.m

@@ -1162,8 +1162,7 @@
     }
     }
 
 
     unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePath error:nil] fileSize];
     unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePath error:nil] fileSize];
-    if (fileSize > 0) return true;
-    else return false;
+    return fileSize == metadata.size;
 }
 }
 
 
 + (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView
 + (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView