Merge "Limit rename() workaround to /storage/emulated." into rvc-dev am: 5019f6c50b am: 24508819d3 am: 9a88158599
Change-Id: I4cdd96eaa8448862ec500fdfe9eb2fb30dd9e6b2
This commit is contained in:
@@ -7513,7 +7513,15 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
try {
|
||||
super.rename(oldPath, newPath);
|
||||
} catch (ErrnoException e) {
|
||||
if (e.errno == OsConstants.EXDEV && oldPath.startsWith("/storage/")) {
|
||||
// On emulated volumes, we have bind mounts for /Android/data and
|
||||
// /Android/obb, which prevents move from working across those directories
|
||||
// and other directories on the filesystem. To work around that, try to
|
||||
// recover by doing a copy instead.
|
||||
// Note that we only do this for "/storage/emulated", because public volumes
|
||||
// don't have these bind mounts, neither do private volumes that are not
|
||||
// the primary storage.
|
||||
if (e.errno == OsConstants.EXDEV && oldPath.startsWith("/storage/emulated")
|
||||
&& newPath.startsWith("/storage/emulated")) {
|
||||
Log.v(TAG, "Recovering failed rename " + oldPath + " to " + newPath);
|
||||
try {
|
||||
Files.move(new File(oldPath).toPath(), new File(newPath).toPath(),
|
||||
|
||||
Reference in New Issue
Block a user