X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d0b7df16e7db7aacfeab0685eb9ceaf6b58fbc08..8361540852ec87b51c85937e0f326a83e19cd8ad:/src/com/owncloud/android/operations/RenameFileOperation.java diff --git a/src/com/owncloud/android/operations/RenameFileOperation.java b/src/com/owncloud/android/operations/RenameFileOperation.java index d5af9767..f4ec7b0a 100644 --- a/src/com/owncloud/android/operations/RenameFileOperation.java +++ b/src/com/owncloud/android/operations/RenameFileOperation.java @@ -29,8 +29,8 @@ import android.util.Log; import com.owncloud.android.datamodel.DataStorageManager; import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.utils.FileStorageUtils; import eu.alefzero.webdav.WebdavClient; import eu.alefzero.webdav.WebdavUtils; @@ -154,10 +154,10 @@ public class RenameFileOperation extends RemoteOperation { private void saveLocalDirectory() { mStorageManager.moveDirectory(mFile, mNewRemotePath); - String localPath = FileDownloader.getSavePath(mAccount.name) + mFile.getRemotePath(); + String localPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile); File localDir = new File(localPath); if (localDir.exists()) { - localDir.renameTo(new File(FileDownloader.getSavePath(mAccount.name) + mNewRemotePath)); + localDir.renameTo(new File(FileStorageUtils.getSavePath(mAccount.name) + mNewRemotePath)); // TODO - if renameTo fails, children files that are already down will result unlinked } } @@ -168,9 +168,11 @@ public class RenameFileOperation extends RemoteOperation { // try to rename the local copy of the file if (mFile.isDown()) { File f = new File(mFile.getStoragePath()); - String newStoragePath = f.getParent() + mNewName; - if (f.renameTo(new File(newStoragePath))) { - mFile.setStoragePath(newStoragePath); + String parentStoragePath = f.getParent(); + if (!parentStoragePath.endsWith(File.separator)) + parentStoragePath += File.separator; + if (f.renameTo(new File(parentStoragePath + mNewName))) { + mFile.setStoragePath(parentStoragePath + mNewName); } // else - NOTHING: the link to the local file is kept although the local name can't be updated // TODO - study conditions when this could be a problem @@ -199,7 +201,7 @@ public class RenameFileOperation extends RemoteOperation { return false; } // create a test file - String tmpFolder = FileDownloader.getTemporalPath(""); + String tmpFolder = FileStorageUtils.getTemporalPath(""); File testFile = new File(tmpFolder + mNewName); try { testFile.createNewFile(); // return value is ignored; it could be 'false' because the file already existed, that doesn't invalidate the name @@ -216,8 +218,7 @@ public class RenameFileOperation extends RemoteOperation { } - - // move operation - TODO: find out why org.apache.jackrabbit.webdav.client.methods.MoveMethod is not used instead ¿? + // move operation private class LocalMoveMethod extends DavMethodBase { public LocalMoveMethod(String uri, String dest) {