From 8aefcff4b1c9aec2b69ceeddd9ba4241a7719385 Mon Sep 17 00:00:00 2001 From: idk Date: Wed, 18 Aug 2021 14:57:30 -0400 Subject: [PATCH] Check return value of renameTo, if false throw an IOException. --- .../i2p/router/WindowsUpdatePostProcessor.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/java/net/i2p/router/WindowsUpdatePostProcessor.java b/java/net/i2p/router/WindowsUpdatePostProcessor.java index b73fc79..74dee18 100644 --- a/java/net/i2p/router/WindowsUpdatePostProcessor.java +++ b/java/net/i2p/router/WindowsUpdatePostProcessor.java @@ -55,12 +55,7 @@ public class WindowsUpdatePostProcessor implements UpdatePostProcessor { return; } - try { - this.positionedFile = moveUpdateInstaller(file); - } catch(IOException ioe) { - _log.error("Error positioning update installer", ioe); - return; - } + this.positionedFile = moveUpdateInstaller(file); this.version = version; if (!hook.compareAndSet(false,true)) { @@ -76,12 +71,14 @@ public class WindowsUpdatePostProcessor implements UpdatePostProcessor { private File moveUpdateInstaller(File file) throws IOException { RouterContext i2pContext = i2pRouter.getContext(); if (i2pContext != null) { - File appDir = i2pContext.getConfigDir(); File newFile = new File(workDir(), file.getName()); - file.renameTo(newFile); - return newFile; + boolean renamedStatus = file.renameTo(newFile); + if (renamedStatus) + return newFile; + else + throw new IOException("WindowsUpdatePostProcesssor unable to move file to working directory, update will fail"); } - return null; + throw new IOException("Router context not available to WindowsUpdatePostProcesssor, unable to find working directory, update will fail"); } private File workDir() throws IOException{