RemoteOperationResult result = mActivity.renameFile(mNewFolderName, mNewFolderPath, mOldFolderName, mOldFolderPath);
assertTrue(result.isSuccess());
- result = mActivity.renameFile(mNewFileName, mNewFilePath, mOldFileName, mOldFilePath);
+ result = mActivity.renameFile(mNewFileName + mFileExtension, mNewFilePath + mFileExtension, mOldFileName, mOldFilePath);
assertTrue(result.isSuccess());
}
return new RemoteOperationResult(ResultCode.OK);
}
+ // check if a file with the new name already exists
+ if (client.existsFile(mNewRemotePath)) {
+ return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE);
+ }
+
move = new LocalMoveMethod( client.getBaseUri() + WebdavUtils.encodePath(mOldRemotePath),
- client.getBaseUri() + WebdavUtils.encodePath(mNewRemotePath));
+ client.getBaseUri() + WebdavUtils.encodePath(mNewRemotePath));
int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT);
move.getResponseBodyAsString(); // exhaust response, although not interesting
mNewRemotePath += OCFile.PATH_SEPARATOR;
}
- // check if a file with the new name already exists
- if (client.existsFile(mNewRemotePath) || // remote check could fail by network failure. by indeterminate behavior of HEAD for folders ...
- mStorageManager.getFileByPath(mNewRemotePath) != null) { // ... so local check is convenient
+ // ckeck local overwrite
+ if (mStorageManager.getFileByPath(mNewRemotePath) != null) {
return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE);
}
-
- RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(), mFile.getRemotePath(), mNewName,
- mNewRemotePath);
- result = operation.execute(client);
+
+ RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(), mFile.getRemotePath(), mNewName,
+ mNewRemotePath);
+ result = operation.execute(client);
- if (result.isSuccess()) {
- if (mFile.isFolder()) {
- saveLocalDirectory();
+ if (result.isSuccess()) {
+ if (mFile.isFolder()) {
+ saveLocalDirectory();
- } else {
- saveLocalFile();
+ } else {
+ saveLocalFile();
+ }
}
- }
} catch (HttpException e) {
Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ? mNewName : mNewRemotePath) + ": " +
((result!= null) ? result.getLogMessage() : ""), e);