Update unsuccessful downloaded file
authorjabarros <jabarros@solidgear.es>
Tue, 20 Jan 2015 12:00:37 +0000 (13:00 +0100)
committerjabarros <jabarros@solidgear.es>
Tue, 20 Jan 2015 12:00:37 +0000 (13:00 +0100)
src/com/owncloud/android/files/services/FileDownloader.java

index 741e30a..61483af 100644 (file)
@@ -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