From 72561926aae05c043b68a47504197cdd222b9dc1 Mon Sep 17 00:00:00 2001 From: sixcooler Date: Wed, 15 Oct 2014 18:13:54 +0200 Subject: [PATCH] do not overwrite yacy.conf in case of an exception may be a fix for http://mantis.tokeek.de/view.php?id=180 --- source/net/yacy/kelondro/util/FileUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/net/yacy/kelondro/util/FileUtils.java b/source/net/yacy/kelondro/util/FileUtils.java index 4a637491a..17faf2da9 100644 --- a/source/net/yacy/kelondro/util/FileUtils.java +++ b/source/net/yacy/kelondro/util/FileUtils.java @@ -403,6 +403,7 @@ public final class FileUtils { private final static Pattern escaped_backslash = Pattern.compile(Pattern.quote("\\"), Pattern.LITERAL); public static void saveMap(final File file, final Map props, final String comment) { + boolean err = false; PrintWriter pw = null; final File tf = new File(file.toString() + "." + (System.currentTimeMillis() % 1000)); try { @@ -428,15 +429,17 @@ public final class FileUtils { pw.println("# EOF"); } catch (final FileNotFoundException e ) { ConcurrentLog.warn("FileUtils", e.getMessage(), e); + err = true; } catch (final UnsupportedEncodingException e ) { ConcurrentLog.warn("FileUtils", e.getMessage(), e); + err = true; } finally { if ( pw != null ) { pw.close(); } pw = null; } - try { + if (!err) try { forceMove(tf, file); } catch (final IOException e ) { // ignore