X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/3f2081e6073bd0c11d672890f350da80abc554b2..4c50eb4d2dd1fba177d743315ae52223430db8cb:/src/com/owncloud/android/files/services/FileDownloader.java diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index f58e563c..5e80f5d3 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -190,14 +190,27 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis /** - * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or waiting to download + * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or waiting to download. + * + * If 'file' is a directory, returns 'true' if some of its descendant files is downloading or waiting to download. * * @param account Owncloud account where the remote file is stored. * @param file A file that could be in the queue of downloads. */ public boolean isDownloading(Account account, OCFile file) { + String targetKey = buildRemoteName(account, file); synchronized (mPendingDownloads) { - return (mPendingDownloads.containsKey(buildRemoteName(account, file))); + if (file.isDirectory()) { + // this can be slow if there are many downloads :( + Iterator it = mPendingDownloads.keySet().iterator(); + boolean found = false; + while (it.hasNext() && !found) { + found = it.next().startsWith(targetKey); + } + return found; + } else { + return (mPendingDownloads.containsKey(targetKey)); + } } } }