slub.team team mailing list archive
-
slub.team team
-
Mailing list archive
-
Message #00115
[Merge] lp:~henning-gerhardt/goobi-production/bug-955790 into lp:goobi-production
Henning Gerhardt has proposed merging lp:~henning-gerhardt/goobi-production/bug-955790 into lp:goobi-production.
Requested reviews:
Ralf Claussnitzer (ralf-claussnitzer)
Related bugs:
Bug #955790 in Goobi.Production: "crashing editor deletes meta data files and backups"
https://bugs.launchpad.net/goobi-production/+bug/955790
For more details, see:
https://code.launchpad.net/~henning-gerhardt/goobi-production/bug-955790/+merge/98990
Changes should prevent overriding of backup files with zero byte files.
--
https://code.launchpad.net/~henning-gerhardt/goobi-production/bug-955790/+merge/98990
Your team Saxon State Library Team is subscribed to branch lp:goobi-production.
=== modified file 'src/de/sub/goobi/beans/Prozess.java'
--- src/de/sub/goobi/beans/Prozess.java 2012-03-13 11:15:48 +0000
+++ src/de/sub/goobi/beans/Prozess.java 2012-03-23 09:44:17 +0000
@@ -745,9 +745,27 @@
return result;
}
+ private void renameMetadataFile(String oldFileName, String newFileName) {
+ File oldFile;
+ File newFile;
+ Long lastModified;
+
+ if (oldFileName != null && newFileName != null) {
+ oldFile = new File(oldFileName);
+ lastModified = oldFile.lastModified();
+ newFile = new File(newFileName);
+ oldFile.renameTo(newFile);
+ newFile.setLastModified(lastModified);
+ }
+ }
+
public void writeMetadataFile(Fileformat gdzfile) throws IOException, InterruptedException, SwapException, DAOException, WriteException,
PreferencesException {
Fileformat ff;
+ String metadataFileName;
+ String metadataFileNameNew;
+ Boolean writeResult;
+
switch (MetadataFormat.findFileFormatsHelperByName(projekt.getFileFormatInternal())) {
case METS:
ff = new MetsMods(regelsatz.getPreferences());
@@ -761,9 +779,16 @@
ff = new XStream(regelsatz.getPreferences());
break;
}
- createBackupFile();
+
+ metadataFileName = getMetadataFilePath();
+ metadataFileNameNew = metadataFileName + ".new";
+
ff.setDigitalDocument(gdzfile.getDigitalDocument());
- ff.write(getMetadataFilePath());
+ writeResult = ff.write(metadataFileNameNew);
+ if (writeResult) {
+ createBackupFile();
+ renameMetadataFile(metadataFileNameNew, metadataFileName);
+ }
}
public void writeMetadataAsTemplateFile(Fileformat inFile) throws IOException, InterruptedException, SwapException, DAOException, WriteException,
Follow ups