From: Mathieu Baudier Date: Mon, 8 May 2023 05:40:51 +0000 (+0200) Subject: FS utils throws IOException X-Git-Tag: v2.3.16~10 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=5787751da1ea80d35427825f4a9ecbf228fa4767;p=lgpl%2Fargeo-commons.git FS utils throws IOException --- diff --git a/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContent.java b/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContent.java index 5920c4203..8fca831b0 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContent.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContent.java @@ -315,7 +315,11 @@ public class FsContent extends AbstractContent implements ProvidedContent { @Override public void remove() { - FsUtils.delete(path); + try { + FsUtils.delete(path); + } catch (IOException e) { + throw new RuntimeException("Cannot delete " + path, e); + } } @Override diff --git a/org.argeo.cms/src/org/argeo/cms/util/FsUtils.java b/org.argeo.cms/src/org/argeo/cms/util/FsUtils.java index 26c05b60e..57555ee53 100644 --- a/org.argeo.cms/src/org/argeo/cms/util/FsUtils.java +++ b/org.argeo.cms/src/org/argeo/cms/util/FsUtils.java @@ -47,28 +47,24 @@ public class FsUtils { * Deletes this path, recursively if needed. Does nothing if the path does not * exist. */ - public static void delete(Path path) { - try { - if (!Files.exists(path)) - return; - Files.walkFileTree(path, new SimpleFileVisitor() { - @Override - public FileVisitResult postVisitDirectory(Path directory, IOException e) throws IOException { - if (e != null) - throw e; - Files.delete(directory); - return FileVisitResult.CONTINUE; - } + public static void delete(Path path) throws IOException { + if (!Files.exists(path)) + return; + Files.walkFileTree(path, new SimpleFileVisitor() { + @Override + public FileVisitResult postVisitDirectory(Path directory, IOException e) throws IOException { + if (e != null) + throw e; + Files.delete(directory); + return FileVisitResult.CONTINUE; + } - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - }); - } catch (IOException e) { - throw new RuntimeException("Cannot delete " + path, e); - } + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + }); } /** Singleton. */