use of com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation in project android by nextcloud.
the class AbstractOnServerIT method deleteAllFiles.
public static void deleteAllFiles() {
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
assertTrue(result.getLogMessage(), result.isSuccess());
for (Object object : result.getData()) {
RemoteFile remoteFile = (RemoteFile) object;
if (!remoteFile.getRemotePath().equals("/")) {
if (remoteFile.isEncrypted()) {
assertTrue(new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(), remoteFile.getRemotePath(), false).execute(client).isSuccess());
}
assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath()).execute(client).isSuccess());
}
}
}
use of com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation in project android by nextcloud.
the class RemoveFileOperation method run.
/**
* Performs the remove operation
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = null;
RemoteOperation operation;
if (MimeTypeUtil.isImage(fileToRemove.getMimeType())) {
// store resized image
ThumbnailsCacheManager.generateResizedImage(fileToRemove);
}
boolean localRemovalFailed = false;
if (!onlyLocalCopy) {
if (fileToRemove.isEncrypted()) {
OCFile parent = getStorageManager().getFileByPath(fileToRemove.getParentRemotePath());
operation = new RemoveRemoteEncryptedFileOperation(fileToRemove.getRemotePath(), parent.getLocalId(), account, context, fileToRemove.getEncryptedFileName());
} else {
operation = new RemoveFileRemoteOperation(fileToRemove.getRemotePath());
}
result = operation.execute(client);
if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) {
localRemovalFailed = !(getStorageManager().removeFile(fileToRemove, true, true));
}
} else {
localRemovalFailed = !(getStorageManager().removeFile(fileToRemove, false, true));
if (!localRemovalFailed) {
result = new RemoteOperationResult(ResultCode.OK);
}
}
if (localRemovalFailed) {
result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_REMOVED);
}
return result;
}
Aggregations