Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78243297 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use REPLACE_EXISTING for rename(2) workaround." into rvc-dev

parents 8829c37c 13885b73
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ import java.lang.reflect.Method;
import java.net.InetAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -7413,8 +7414,10 @@ public final class ActivityThread extends ClientTransactionHandler {
                if (e.errno == OsConstants.EXDEV && oldPath.startsWith("/storage/")) {
                    Log.v(TAG, "Recovering failed rename " + oldPath + " to " + newPath);
                    try {
                        Files.move(new File(oldPath).toPath(), new File(newPath).toPath());
                        Files.move(new File(oldPath).toPath(), new File(newPath).toPath(),
                                StandardCopyOption.REPLACE_EXISTING);
                    } catch (IOException e2) {
                        Log.e(TAG, "Rename recovery failed ", e);
                        throw e;
                    }
                } else {