Improved bug fix refs #10677

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/document-store-lib@161868 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-12-22 14:05:42 +00:00
parent 78c2c67252
commit eecbbb1018
2 changed files with 5 additions and 3 deletions

View File

@ -101,9 +101,7 @@ public class FallbackMonitor implements Runnable {
Long timestamp = Calendar.getInstance().getTimeInMillis();
File elaborationFile = fallbackPersistenceBackend.moveFallbackFile(ELABORATION_FILE_SUFFIX + "." + timestamp.toString());
elaborateFallbackFile(elaborationFile);
}
@Override

View File

@ -52,12 +52,16 @@ public class FallbackPersistenceBackend extends PersistenceBackend {
/**
* Move the fallbackFile to a new file with the same name by appending a suffix
* @param suffix
* @return the move file
* @return the moved file if any, null otherwise
*/
protected File moveFallbackFile(String suffix) {
synchronized(fallbackFile) {
try {
Path source = fallbackFile.toPath();
if(!fallbackFile.exists()) {
logger.trace("No fallback file {} found. Nothing to recover", source.toAbsolutePath().toString());
return null;
}
Path target = source.resolveSibling(fallbackFile.getName()+suffix);
logger.trace("Going to move fallback file {} to {}", source.toAbsolutePath().toString(), target.toAbsolutePath().toString());
target = Files.move(source, source.resolveSibling(fallbackFile.getName()+suffix), StandardCopyOption.ATOMIC_MOVE);