- DeleteMethod delete = null;
- try {
- delete = new DeleteMethod(client.getBaseUri() + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));
- int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT);
- if (delete.succeeded() || status == HttpStatus.SC_NOT_FOUND) {
- if (mFileToRemove.isFolder()) {
- mDataStorageManager.removeFolder(mFileToRemove, true, mDeleteLocalCopy);
- } else {
- mDataStorageManager.removeFile(mFileToRemove, mDeleteLocalCopy);
- }
- }
- delete.getResponseBodyAsString(); // exhaust the response, although not interesting
- result = new RemoteOperationResult((delete.succeeded() || status == HttpStatus.SC_NOT_FOUND), status, delete.getResponseHeaders());
- Log_OC.i(TAG, "Remove " + mFileToRemove.getRemotePath() + ": " + result.getLogMessage());
-
- } catch (Exception e) {
- result = new RemoteOperationResult(e);
- Log_OC.e(TAG, "Remove " + mFileToRemove.getRemotePath() + ": " + result.getLogMessage(), e);
-
- } finally {
- if (delete != null)
- delete.releaseConnection();
+
+ RemoveRemoteFileOperation operation = new RemoveRemoteFileOperation(mFileToRemove.getRemotePath());
+ result = operation.execute(client);
+
+ if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) {
+ mDataStorageManager.removeFile(mFileToRemove, true, mDeleteLocalCopy);