瀏覽代碼

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