From 0f9e09d74b6ce58c0b6509446141b17b898d2419 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Fri, 25 Oct 2024 16:25:55 -0700 Subject: Fix how we delete the symlink The previous way of checking the file existance would be fooled if the symlink exists but the target doesn't. Flag: EXEMPT host test change only Fix: 369687596 Test: manual $ rm /tmp/Ravenwood-stats_CtsOsTestCasesRavenwood_2*.csv # remove only the target $ atest CtsOsTestCasesRavenwood Change-Id: I84c94ca5913182a06422f71743a3b809ab805fda --- .../android/platform/test/ravenwood/RavenwoodTestStats.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'ravenwood/junit-impl-src/android') diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java index b4b871524291..016de8e45291 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java @@ -90,9 +90,7 @@ public class RavenwoodTestStats { // Create the "latest" symlink. Path symlink = Paths.get(tmpdir, basename + "latest.csv"); try { - if (Files.exists(symlink)) { - Files.delete(symlink); - } + Files.deleteIfExists(symlink); Files.createSymbolicLink(symlink, Paths.get(mOutputFile.getName())); } catch (IOException e) { -- cgit v1.2.3-59-g8ed1b