- public void add(Account account, String remotePath, SynchronizeFolderOperation syncFolderOperation){
- String syncKey = buildRemoteName(account,remotePath);
- mPendingOperations.putIfAbsent(syncKey,syncFolderOperation);
- }
-
-
- /**
- * Cancels a pending or current sync operation.
- *
- * @param account Owncloud account where the remote file is stored.
- * @param file File
- */
- public void cancel(Account account, OCFile file) {
- SynchronizeFolderOperation syncOperation = null;
- synchronized (mPendingOperations) {
- syncOperation = mPendingOperations.remove(buildRemoteName(account, file.getRemotePath()));
- }
- if (syncOperation != null) {
- syncOperation.cancel();
- }
-
- Intent intent = new Intent( MainApp.getAppContext(), FileDownloader.class);
- intent.setAction(FileDownloader.ACTION_CANCEL_FILE_DOWNLOAD);
- intent.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
- intent.putExtra(FileDownloader.EXTRA_FILE, file);
- MainApp.getAppContext().startService(intent);
-
- }
-
- /**
- * Builds a key from the account and file to download
- *
- * @param account Account where the file to download is stored
- * @param path File path
- */
- private String buildRemoteName(Account account, String path) {
- return account.name + path;
- }