From: masensio Date: Mon, 2 Feb 2015 13:51:46 +0000 (+0100) Subject: Cancel transfers of an account when it detects that the account doesn't exist X-Git-Tag: oc-android-1.7.1_signed^2~40^2~17 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/aa7b7af7212e68a52bd2234a9fa7801b6d3006c5?ds=inline;hp=-c Cancel transfers of an account when it detects that the account doesn't exist --- aa7b7af7212e68a52bd2234a9fa7801b6d3006c5 diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index f9c57ccf..f56e1b57 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -327,7 +327,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe return false; // not accepting rebinding (default behaviour) } - /** * Binder to let client components to perform operations on the queue of * uploads. @@ -357,15 +356,10 @@ public class FileUploader extends Service implements OnDatatransferProgressListe } } - - public void clearListeners() { mBoundListeners.clear(); } - - - /** * Returns True when the file described by 'file' is being uploaded to * the ownCloud account 'account' or waiting for it @@ -548,6 +542,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe } else { // Cancel the transfer Log_OC.d(TAG, "Account " + mCurrentUpload.getAccount().toString() + " doesn't exist"); + cancelUploadForAccount(mCurrentUpload.getAccount().name); + } } @@ -887,4 +883,21 @@ public class FileUploader extends Service implements OnDatatransferProgressListe !localPath.endsWith(FILE_EXTENSION_PDF); } + /** + * Remove uploads of an account + * @param accountName + */ + private void cancelUploadForAccount(String accountName){ + // this can be slow if there are many uploads :( + Iterator it = mPendingUploads.keySet().iterator(); + Log_OC.d(TAG, "Number of pending updloads= " + mPendingUploads.size()); + boolean found; + while (it.hasNext()) { + String key = it.next(); + Log_OC.d(TAG, "mPendingUploads CANCELLED" + key); + if (key.startsWith(accountName)) { + mPendingUploads.remove(key); + } + } + } }