*/
private void cancelDownloadsForAccount(Account account) {
// Cancel pending downloads
- ConcurrentMap downloadsAccount = mPendingDownloads.get(account);
- Iterator<String> it = downloadsAccount.keySet().iterator();
- Log_OC.d(TAG, "Number of pending downloads= " + downloadsAccount.size());
- DownloadFileOperation download;
- while (it.hasNext()) {
- String key = it.next();
- Log_OC.d(TAG, "download CANCELLED " + key);
- if (key.startsWith(account.name)) {
- synchronized (mPendingDownloads) {
- download = mPendingDownloads.get(key);
- if (download != null) {
- String remotePath = download.getRemotePath();
- mPendingDownloads.remove(account, remotePath);
- }
- }
- }
- }
+ mPendingDownloads.remove(account);
}
}
}
- public ConcurrentMap<String, Node<V>> get(Account account){
- ConcurrentMap<String, Node<V>> accountMap = new ConcurrentHashMap<String, Node<V>>();
+ /**
+ * Remove the elements that contains account as a part of its key
+ * @param account
+ */
+ public void remove(Account account){
Iterator<String> it = mMap.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
Log_OC.d("IndexedForest", "Number of pending downloads= " + mMap.size());
if (key.startsWith(account.name)) {
- accountMap.putIfAbsent(key, mMap.get(key));
+ mMap.remove(key);
}
}
- return accountMap;
}
/**