projects
/
pub
/
Android
/
ownCloud.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6e092bf
)
FIX OC-2101: App crash when renaming a folder while the server is down or without...
author
masensio
<masensio@solidgear.es>
Mon, 18 Nov 2013 11:07:54 +0000
(12:07 +0100)
committer
masensio
<masensio@solidgear.es>
Mon, 18 Nov 2013 11:07:54 +0000
(12:07 +0100)
oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java
patch
|
blob
|
blame
|
history
oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/operations/RenameFileOperation.java
patch
|
blob
|
blame
|
history
diff --git
a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java
b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java
index
015565c
..
f4c2cf6
100644
(file)
--- a/
oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java
+++ b/
oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java
@@
-151,7
+151,7
@@
public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
RemoteOperationResult result = mActivity.renameFile(mNewFolderName, mNewFolderPath, mOldFolderName, mOldFolderPath);
assertTrue(result.isSuccess());
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());
}
assertTrue(result.isSuccess());
}
diff --git
a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java
b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java
index
cecf07d
..
c05c4ca
100644
(file)
--- a/
oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java
+++ b/
oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java
@@
-66,8
+66,13
@@
public class RenameRemoteFileOperation extends RemoteOperation {
return new RemoteOperationResult(ResultCode.OK);
}
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),
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
int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT);
move.getResponseBodyAsString(); // exhaust response, although not interesting
diff --git
a/src/com/owncloud/android/operations/RenameFileOperation.java
b/src/com/owncloud/android/operations/RenameFileOperation.java
index
69ca2f2
..
a526f2f
100644
(file)
--- a/
src/com/owncloud/android/operations/RenameFileOperation.java
+++ b/
src/com/owncloud/android/operations/RenameFileOperation.java
@@
-93,24
+93,23
@@
public class RenameFileOperation extends RemoteOperation {
mNewRemotePath += OCFile.PATH_SEPARATOR;
}
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);
}
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);
} catch (HttpException e) {
Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ? mNewName : mNewRemotePath) + ": " +
((result!= null) ? result.getLogMessage() : ""), e);