소스 검색

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);