[Fix] Don't read XML files starting with .tmp_ our temp file prefix
This commit is contained in:
parent
320fc01624
commit
898afd98b9
|
@ -46,13 +46,14 @@ public class FileIo {
|
|||
public static final String DEFAULT_ENCODING = "utf-8"; //$NON-NLS-1$
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileIo.class);
|
||||
public static final String TMP_PREFIX = ".tmp_";
|
||||
|
||||
private final File path;
|
||||
private final File tmpPath;
|
||||
|
||||
public FileIo(File path) {
|
||||
this.path = path;
|
||||
this.tmpPath = new File(this.path.getParentFile(), ".tmp_" + this.path.getName());
|
||||
this.tmpPath = new File(this.path.getParentFile(), TMP_PREFIX + this.path.getName());
|
||||
}
|
||||
|
||||
public <T> void writeSax(PersistenceContext<T> ctx) {
|
||||
|
@ -160,7 +161,7 @@ public class FileIo {
|
|||
|
||||
// Transform to file
|
||||
try (Writer ioWriter = new OutputStreamWriter(new FileOutputStream(this.tmpPath), encoding)) {
|
||||
StreamResult result = new StreamResult(this.tmpPath);
|
||||
StreamResult result = new StreamResult(ioWriter);
|
||||
Source xmlSource = new DOMSource(document);
|
||||
transformer.transform(xmlSource, result);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package li.strolch.xmlpers.api;
|
||||
|
||||
import static li.strolch.xmlpers.api.FileIo.TMP_PREFIX;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collections;
|
||||
|
@ -138,10 +140,12 @@ public class MetadataDao {
|
|||
|
||||
Set<String> keySet = new TreeSet<>();
|
||||
File[] subTypeFiles = queryPath.listFiles();
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
if (subTypeFile.isDirectory()) {
|
||||
String type = subTypeFile.getName();
|
||||
keySet.add(type);
|
||||
if (subTypeFiles != null) {
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
if (subTypeFile.isDirectory()) {
|
||||
String type = subTypeFile.getName();
|
||||
keySet.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +182,7 @@ public class MetadataDao {
|
|||
}
|
||||
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
if (subTypeFile.isFile()) {
|
||||
if (subTypeFile.isFile() && !subTypeFile.getName().startsWith(TMP_PREFIX)) {
|
||||
String filename = subTypeFile.getName();
|
||||
String id = FilenameUtility.getId(filename);
|
||||
keySet.add(id);
|
||||
|
@ -206,13 +210,15 @@ public class MetadataDao {
|
|||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
long numberOfFiles = 0l;
|
||||
long numberOfFiles = 0L;
|
||||
|
||||
File[] subTypeFiles = queryPath.listFiles();
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
if (subTypeFiles != null) {
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
|
||||
if (subTypeFile.isDirectory())
|
||||
numberOfFiles++;
|
||||
if (subTypeFile.isDirectory())
|
||||
numberOfFiles++;
|
||||
}
|
||||
}
|
||||
return numberOfFiles;
|
||||
}
|
||||
|
@ -235,13 +241,15 @@ public class MetadataDao {
|
|||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
long numberOfFiles = 0l;
|
||||
long numberOfFiles = 0L;
|
||||
|
||||
File[] subTypeFiles = queryPath.listFiles();
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
if (subTypeFiles != null) {
|
||||
for (File subTypeFile : subTypeFiles) {
|
||||
|
||||
if (subTypeFile.isFile())
|
||||
numberOfFiles++;
|
||||
if (subTypeFile.isFile() && !subTypeFile.getName().startsWith(TMP_PREFIX))
|
||||
numberOfFiles++;
|
||||
}
|
||||
}
|
||||
return numberOfFiles;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue