- * Cancel operation
- * @param account ownCloud account where the remote file is stored.
- * @param file File OCFile
- *-/
- public void cancel(Account account, OCFile file){
- DownloadFileOperation download = null;
- //String targetKey = buildKey(account, file.getRemotePath());
- ArrayList<String> keyItems = new ArrayList<String>();
- if (file.isFolder()) {
- Log_OC.d(TAG, "Folder download. Canceling pending downloads (from folder)");
-
- // TODO
- /*
- Iterator<String> it = mPendingDownloads.keySet().iterator();
- boolean found = false;
- while (it.hasNext()) {
- String keyDownloadOperation = it.next();
- found = keyDownloadOperation.startsWith(targetKey);
- if (found) {
- keyItems.add(keyDownloadOperation);
- }
- }
-
- for (String item: keyItems) {
- download = mPendingDownloads.remove(item);
- Log_OC.d(TAG, "Key removed: " + item);
-
- if (download != null) {
- download.cancel();
- }
- }
-
- *-/
-
- } else {
- // this is not really expected...
- Log_OC.d(TAG, "Canceling file download");
- download = mPendingDownloads.remove(account, file.getRemotePath());
- if (download != null) {
- download.cancel();
- }
- }
+ * Remove downloads of an account
+ *
+ * @param account Downloads account to remove
+ */
+ private void cancelDownloadsForAccount(Account account) {
+ // Cancel pending downloads
+ mPendingDownloads.remove(account);