aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohit Yengisetty <rohit@cyngn.com>2015-03-05 16:35:21 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-03-21 14:29:28 +0000
commitdf97de0cff704f0bfbd70fffe0f3cee346dbfa15 (patch)
treeea1133b13e9e943c230073aac8deb6a057daf33d
parent2185846e4a2927563263c15a7a09061d0f7624a7 (diff)
downloadandroid_packages_apps_CMFileManager-df97de0cff704f0bfbd70fffe0f3cee346dbfa15.tar.gz
android_packages_apps_CMFileManager-df97de0cff704f0bfbd70fffe0f3cee346dbfa15.tar.bz2
android_packages_apps_CMFileManager-df97de0cff704f0bfbd70fffe0f3cee346dbfa15.zip
CM File Manager - Gracefully handle renaming on case-insensitive filesystems
Add edge case handling to move/copy commands wherein something is being renamed to a different-cased version of itself. Ex : renaming 'mydocuments' to 'MyDocuments' https://jira.cyanogenmod.org/browse/BACON-3074 Change-Id: Id90de5fd083e341371f250c0194f200388cf4941
-rw-r--r--src/com/cyanogenmod/filemanager/util/CommandHelper.java6
-rw-r--r--src/com/cyanogenmod/filemanager/util/FileHelper.java15
2 files changed, 19 insertions, 2 deletions
diff --git a/src/com/cyanogenmod/filemanager/util/CommandHelper.java b/src/com/cyanogenmod/filemanager/util/CommandHelper.java
index 6c33a2f6..de717989 100644
--- a/src/com/cyanogenmod/filemanager/util/CommandHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/CommandHelper.java
@@ -766,10 +766,11 @@ public final class CommandHelper {
CommandNotFoundException, OperationTimeoutException,
ExecutionException, InvalidCommandDefinitionException, ReadOnlyFilesystemException,
CancelledOperationException {
+
Console cSrc = ensureConsoleForFile(context, console, src);
Console cDst = ensureConsoleForFile(context, console, dst);
boolean ret = true;
- if (cSrc.equals(cDst)) {
+ if (cSrc.equals(cDst) && !FileHelper.isSamePath(src, dst)) {
// Is safe to use the same console
MoveExecutable executable =
cSrc.getExecutableFactory().newCreator().createMoveExecutable(src, dst);
@@ -858,10 +859,11 @@ public final class CommandHelper {
CommandNotFoundException, OperationTimeoutException,
ExecutionException, InvalidCommandDefinitionException, ReadOnlyFilesystemException,
CancelledOperationException {
+
Console cSrc = ensureConsoleForFile(context, console, src);
Console cDst = ensureConsoleForFile(context, console, dst);
boolean ret = true;
- if (cSrc.equals(cDst)) {
+ if (cSrc.equals(cDst) && !FileHelper.isSamePath(src, dst)) {
// Is safe to use the same console
CopyExecutable executable =
cSrc.getExecutableFactory().newCreator().createCopyExecutable(src, dst);
diff --git a/src/com/cyanogenmod/filemanager/util/FileHelper.java b/src/com/cyanogenmod/filemanager/util/FileHelper.java
index 1d9aa9f2..14059d69 100644
--- a/src/com/cyanogenmod/filemanager/util/FileHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/FileHelper.java
@@ -1501,4 +1501,19 @@ public final class FileHelper {
}
return src.getAbsolutePath().startsWith(dir.getAbsolutePath());
}
+
+ /**
+ * Method that checks if both path are the same (by checking sensitive cases).
+ *
+ * @param src The source path
+ * @param dst The destination path
+ * @return boolean If both are the same path
+ */
+ public static boolean isSamePath(String src, String dst) {
+ // This is only true if both are exactly the same path or the same file in insensitive
+ // file systems
+ File o1 = new File(src);
+ File o2 = new File(dst);
+ return o1.equals(o2);
+ }
}