X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/ffb5702b2d4160aaa9b5216f24b50a240b2a0130..2717c2a2197ae3dfd2fc34b0db97a80fb1540038:/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 20ba041c..178c4d39 100644 --- a/src/com/owncloud/android/operations/RenameFileOperation.java +++ b/src/com/owncloud/android/operations/RenameFileOperation.java @@ -24,10 +24,10 @@ import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.RenameRemoteFileOperation; import com.owncloud.android.operations.common.SyncOperation; import com.owncloud.android.utils.FileStorageUtils; -import com.owncloud.android.utils.Log_OC; import android.accounts.Account; @@ -56,7 +56,6 @@ public class RenameFileOperation extends SyncOperation { * @param remotePath RemotePath of the OCFile instance describing the remote file or folder to rename * @param account OwnCloud account containing the remote file * @param newName New name to set as the name of file. - * @param storageManager Reference to the local database corresponding to the account where the file is contained. */ public RenameFileOperation(String remotePath, Account account, String newName) { mRemotePath = remotePath; @@ -135,12 +134,19 @@ public class RenameFileOperation extends SyncOperation { // try to rename the local copy of the file if (mFile.isDown()) { - File f = new File(mFile.getStoragePath()); + String oldPath = mFile.getStoragePath(); + File f = new File(oldPath); String parentStoragePath = f.getParent(); if (!parentStoragePath.endsWith(File.separator)) parentStoragePath += File.separator; if (f.renameTo(new File(parentStoragePath + mNewName))) { - mFile.setStoragePath(parentStoragePath + mNewName); + String newPath = parentStoragePath + mNewName; + mFile.setStoragePath(newPath); + + // notify MediaScanner about removed file - TODO really works? + getStorageManager().triggerMediaScan(oldPath); + // notify to scan about new file + getStorageManager().triggerMediaScan(newPath); } // 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