- try {
- /// 1. check move validity
-
-
- /// 2. remove move
- MoveRemoteFileOperation operation = new MoveRemoteFileOperation(
- mFile.getRemotePath(),
- mNewPath,
- false
- );
- result = operation.execute(client);
-
-
- /// 3. local move
- if (result.isSuccess()) {
- //moveLocaly();
- /*
- if (mFile.isFolder()) {
- saveLocalDirectory();
-
- } else {
- saveLocalFile();
- }
- */
- }
-
-
- String parentPath = (new File(mFile.getRemotePath())).getParent();
- parentPath = (parentPath.endsWith(OCFile.PATH_SEPARATOR))
- ? parentPath
- : parentPath + OCFile.PATH_SEPARATOR;
-
- mNewPath = mNewParentPath + mFile.getFileName();
- if (mFile.isFolder() && !mNewPath.endsWith(OCFile.PATH_SEPARATOR)) {
- mNewPath += OCFile.PATH_SEPARATOR;
- }
-
- // check local overwrite
- if (getStorageManager().getFileByPath(mPath) != null) {
- return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE);
- }
-
- /*
- } catch (IOException e) {
- Log_OC.e(TAG, "Move " + mFile.getRemotePath() + " to " +
- (mNewParentPath==null) + ": " +
- ((result!= null) ? result.getLogMessage() : ""), e);*/
- } finally {
-
- }
-
- return result;
- }
-
-
- private void saveLocalDirectory() {
- getStorageManager().moveFolder(mFile, mNewPath);
- String localPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
- File localDir = new File(localPath);
- if (localDir.exists()) {
- localDir.renameTo(new File(FileStorageUtils.getSavePath(mAccount.name) + mNewPath));
- // TODO - if renameTo fails, children files that are already down will result unlinked