瀏覽代碼

use modification date from server

Signed-off-by: tobiaskaminsky <tobias@kaminsky.me>
tobiaskaminsky 7 年之前
父節點
當前提交
e5988fe7c7

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

@@ -212,6 +212,7 @@ public class DownloadFileOperation extends RemoteOperation {
                 }
             }
             moved = tmpFile.renameTo(newFile);
+            newFile.setLastModified(mFile.getModificationTimestamp());
             if (!moved) {
                 result = new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
             }

+ 10 - 7
src/main/java/com/owncloud/android/utils/FileStorageUtils.java

@@ -334,13 +334,16 @@ public class FileStorageUtils {
         long lastModified = 0;
         long lastSize = 0;
         File realFile = new File(file.getStoragePath());
-        while ((realFile.lastModified() != lastModified) && (realFile.length() != lastSize)) {
-            lastModified = realFile.lastModified();
-            lastSize = realFile.length();
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException e) {
-                Log.d(TAG, "Failed to sleep for a bit");
+
+        if (realFile.lastModified() != file.getModificationTimestamp() && realFile.length() != file.getFileLength()) {
+            while ((realFile.lastModified() != lastModified) && (realFile.length() != lastSize)) {
+                lastModified = realFile.lastModified();
+                lastSize = realFile.length();
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                    Log.d(TAG, "Failed to sleep for a bit");
+                }
             }
         }