瀏覽代碼

Update unsuccessful downloaded file

jabarros 10 年之前
父節點
當前提交
dea36157e7
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      src/com/owncloud/android/files/services/FileDownloader.java

+ 11 - 0
src/com/owncloud/android/files/services/FileDownloader.java

@@ -383,6 +383,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 downloadResult = mCurrentDownload.execute(mDownloadClient);
                 if (downloadResult.isSuccess()) {
                     saveDownloadedFile();
+                } else {
+                    updateUnsuccessfulDownloadedFile();
                 }
             
             } catch (AccountsException e) {
@@ -428,6 +430,15 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         mStorageManager.triggerMediaScan(file.getStoragePath());
     }
 
+    /**
+     * Update the OC File after a unsuccessful download
+     */
+    private void updateUnsuccessfulDownloadedFile() {
+        OCFile file = mStorageManager.getFileById(mCurrentDownload.getFile().getFileId());
+        file.setDownloading(false);
+        mStorageManager.saveFile(file);
+    }
+
 
     /**
      * Creates a status notification to show the download progress