From: David A. Velasco Date: Tue, 13 Nov 2012 09:39:37 +0000 (+0100) Subject: Grant that a favourite file in the device is watched if a redownload fails X-Git-Tag: oc-android-1.4.3~110 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/4460e43145ab8d50a46e3195a90002d292b58bfb?ds=inline;hp=--cc Grant that a favourite file in the device is watched if a redownload fails --- 4460e43145ab8d50a46e3195a90002d292b58bfb diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 8488294e..a07b0823 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -368,9 +368,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess()); end.putExtra(ACCOUNT_NAME, download.getAccount().name); end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath()); - if (downloadResult.isSuccess()) { - end.putExtra(EXTRA_FILE_PATH, download.getSavePath()); - } + end.putExtra(EXTRA_FILE_PATH, download.getSavePath()); sendBroadcast(end); } diff --git a/src/com/owncloud/android/files/services/FileObserverService.java b/src/com/owncloud/android/files/services/FileObserverService.java index 4cb16de1..70b6b21a 100644 --- a/src/com/owncloud/android/files/services/FileObserverService.java +++ b/src/com/owncloud/android/files/services/FileObserverService.java @@ -18,6 +18,7 @@ package com.owncloud.android.files.services; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -257,12 +258,16 @@ public class FileObserverService extends Service implements FileObserverStatusLi @Override public void onReceive(Context context, Intent intent) { - if (mPath.equals(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH))) { // ISSUE 3: this condition will be false if the download failed; in that case, the download won't ever be retried - context.unregisterReceiver(this); - removeReceiverFromList(this); - mObserver.startWatching(); - Log.d(TAG, "Started watching " + mPath); - return; + if (mPath.equals(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH))) { + if ((new File(mPath)).exists()) { + // the download could be successful, or not; in both cases, the file could be down, due to a former download or upload + context.unregisterReceiver(this); + removeReceiverFromList(this); + mObserver.startWatching(); + Log.d(TAG, "Started watching " + mPath); + return; + } // else - keep waiting for a future retry of the download ; + // mObserver.startWatching() won't ever work if the file is not in the device when it's called } }