+
+ /**
+ * Cancels a pending or current upload for an account
+ *
+ * @param account Owncloud accountName where the remote file will be stored.
+ */
+ public void cancel(Account account) {
+ Log_OC.d(TAG, "Account= " + account.name);
+
+ if (mCurrentDownload != null) {
+ Log_OC.d(TAG, "Current Download Account= " + mCurrentDownload.getAccount().name);
+ if (mCurrentDownload.getAccount().name.equals(account.name)) {
+ mCurrentDownload.cancel();
+ }
+ }
+ // Cancel pending downloads
+ ConcurrentMap downloadsAccount = mPendingDownloads.get(account);
+ Iterator<String> it = downloadsAccount.keySet().iterator();
+ Log_OC.d(TAG, "Number of pending downloads= " + downloadsAccount.size());
+ while (it.hasNext()) {
+ String key = it.next();
+ Log_OC.d(TAG, "download CANCELLED " + key);
+ if (key.startsWith(account.name)) {
+ DownloadFileOperation download;
+ synchronized (mPendingDownloads) {
+ download = mPendingDownloads.get(key);
+ if (download != null) {
+ String remotePath = download.getRemotePath();
+ if (mPendingDownloads.contains(account, remotePath)) {
+ mPendingDownloads.remove(account, remotePath);
+ }
+ }
+ }
+ }
+ }
+ }