[Fix] Don't delete other user's files!
This commit is contained in:
parent
f086143e82
commit
757300e955
|
@ -100,7 +100,7 @@ public class XmlExportModelCommand extends Command {
|
||||||
File[] existingFiles = parentFile.listFiles(new FilenameFilter() {
|
File[] existingFiles = parentFile.listFiles(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.startsWith(exportName);
|
return name.startsWith(exportName) && name.endsWith(".xml");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -119,7 +119,10 @@ public class XmlExportModelCommand extends Command {
|
||||||
this.statistics.startTime = new Date();
|
this.statistics.startTime = new Date();
|
||||||
|
|
||||||
String exportName = fileName.substring(0, fileName.indexOf(XML_FILE_SUFFIX));
|
String exportName = fileName.substring(0, fileName.indexOf(XML_FILE_SUFFIX));
|
||||||
cleanUpExisting(exportName);
|
|
||||||
|
// only delete existing files if doing multi-file
|
||||||
|
if (this.multiFile)
|
||||||
|
cleanUpExisting(exportName);
|
||||||
|
|
||||||
Set<File> createdFiles = new HashSet<>();
|
Set<File> createdFiles = new HashSet<>();
|
||||||
|
|
||||||
|
@ -184,8 +187,8 @@ public class XmlExportModelCommand extends Command {
|
||||||
|
|
||||||
File typeXmlFileF = new File(this.modelFile.getParentFile(), typeXmlFile);
|
File typeXmlFileF = new File(this.modelFile.getParentFile(), typeXmlFile);
|
||||||
DBC.INTERIM.assertNotExists("The type file should not exist with name.", typeXmlFileF);
|
DBC.INTERIM.assertNotExists("The type file should not exist with name.", typeXmlFileF);
|
||||||
logger.info("Writing " + resourceMap.querySize(tx(), type) + " " + type
|
logger.info("Writing " + resourceMap.querySize(tx(), type) + " " + type + " Resources to path: "
|
||||||
+ " Resources to path: " + typeXmlFileF.getAbsolutePath() + "...");
|
+ typeXmlFileF.getAbsolutePath() + "...");
|
||||||
try (FileOutputStream typeOut = new FileOutputStream(typeXmlFileF)) {
|
try (FileOutputStream typeOut = new FileOutputStream(typeXmlFileF)) {
|
||||||
createdFiles.add(typeXmlFileF);
|
createdFiles.add(typeXmlFileF);
|
||||||
XMLStreamWriter typeWriter = openXmlStreamWriter(typeOut);
|
XMLStreamWriter typeWriter = openXmlStreamWriter(typeOut);
|
||||||
|
@ -320,8 +323,8 @@ public class XmlExportModelCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private XMLStreamWriter openXmlStreamWriter(FileOutputStream out) throws FactoryConfigurationError,
|
private XMLStreamWriter openXmlStreamWriter(FileOutputStream out)
|
||||||
XMLStreamException {
|
throws FactoryConfigurationError, XMLStreamException {
|
||||||
XMLOutputFactory factory = XMLOutputFactory.newInstance();
|
XMLOutputFactory factory = XMLOutputFactory.newInstance();
|
||||||
XMLStreamWriter writer = factory.createXMLStreamWriter(out, StrolchConstants.DEFAULT_ENCODING);
|
XMLStreamWriter writer = factory.createXMLStreamWriter(out, StrolchConstants.DEFAULT_ENCODING);
|
||||||
writer = new IndentingXMLStreamWriter(writer);
|
writer = new IndentingXMLStreamWriter(writer);
|
||||||
|
|
Loading…
Reference in New Issue