Преглед на файлове

DownloadFileOperation: use moveFile instead of File.renameTo

File.renameTo fails if both files aren't under the same mountpoint.
As the tmp file is in internal storage now, it has to be move differently if the target dir is in external storage.

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas преди 3 години
родител
ревизия
f18f72abcd
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      src/main/java/com/owncloud/android/operations/DownloadFileOperation.java

+ 3 - 1
src/main/java/com/owncloud/android/operations/DownloadFileOperation.java

@@ -23,6 +23,7 @@ package com.owncloud.android.operations;
 
 import android.accounts.Account;
 import android.content.Context;
+import android.os.FileUtils;
 import android.text.TextUtils;
 import android.webkit.MimeTypeMap;
 
@@ -203,7 +204,8 @@ public class DownloadFileOperation extends RemoteOperation {
                     return new RemoteOperationResult(e);
                 }
             }
-            moved = tmpFile.renameTo(newFile);
+
+            moved = FileStorageUtils.moveFile(tmpFile, newFile);
             newFile.setLastModified(file.getModificationTimestamp());
             if (!moved) {
                 result = new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);