From 3432a662d8ef617b5a923214e238f07cae318d95 Mon Sep 17 00:00:00 2001 From: nikhilchowdary Date: Mon, 27 Feb 2017 00:13:04 +0530 Subject: [PATCH] Fixes #434 --- .../toolkit/activity/TemplateEditor.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java index 522cb6a4..4b1f3fb6 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java @@ -898,13 +898,21 @@ private String saveDraft() { oldFile = new File(oldFileName); FileUtils.saveXmlFile(toolkit.getDraftDir(), ".temp", doc); - if (oldFile == null || !FileUtils.equalContent(tempFile, oldFile)) { + + if(oldFile == null){ tempFile.renameTo(probableFile); return toolkit.getDraftDir() + probableFileName; - } else { + } + else if (!FileUtils.equalContent(tempFile, oldFile)){ + tempFile.renameTo(probableFile); + oldFile.delete(); + return toolkit.getDraftDir() + probableFileName; + } + else { File newFile = new File(toolkit.getDraftDir(), ".temp"); newFile.delete(); } + return null; } catch (ParserConfigurationException | NullPointerException e) { @@ -981,7 +989,7 @@ private void parseSavedFile(String path) { File draftDir = new File(toolkit.getDraftDir()); if (fXmlFile.getParentFile().compareTo(draftDir) == 0) { //If Draft File - fXmlFile.delete(); + // fXmlFile.delete(); } setUpActionBar();