fix journal purging
This commit is contained in:
parent
acdbd0c028
commit
3f8520ed95
1 changed files with 22 additions and 18 deletions
|
@ -109,17 +109,19 @@ public class Journal {
|
|||
writeLock.lock();
|
||||
PathMatcher pathMatcher = journalPath.getFileSystem().getPathMatcher("glob:*.request");
|
||||
try {
|
||||
Files.walkFileTree(journalPath.resolve("success"), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path p, BasicFileAttributes a) throws IOException {
|
||||
if ((Files.isRegularFile(p) && pathMatcher.matches(p.getFileName()))) {
|
||||
if (Files.getLastModifiedTime(p).toInstant().isBefore(instant)) {
|
||||
Files.delete(p);
|
||||
if (Files.exists(journalPath.resolve("success"))) {
|
||||
Files.walkFileTree(journalPath.resolve("success"), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path p, BasicFileAttributes a) throws IOException {
|
||||
if ((Files.isRegularFile(p) && pathMatcher.matches(p.getFileName()))) {
|
||||
if (Files.getLastModifiedTime(p).toInstant().isBefore(instant)) {
|
||||
Files.delete(p);
|
||||
}
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
}
|
||||
|
@ -130,17 +132,19 @@ public class Journal {
|
|||
writeLock.lock();
|
||||
PathMatcher pathMatcher = journalPath.getFileSystem().getPathMatcher("glob:*.request");
|
||||
try {
|
||||
Files.walkFileTree(journalPath.resolve("fail"), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path p, BasicFileAttributes a) throws IOException {
|
||||
if ((Files.isRegularFile(p) && pathMatcher.matches(p.getFileName()))) {
|
||||
if (Files.getLastModifiedTime(p).toInstant().isBefore(instant)) {
|
||||
Files.delete(p);
|
||||
if (Files.exists(journalPath.resolve("fail"))) {
|
||||
Files.walkFileTree(journalPath.resolve("fail"), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path p, BasicFileAttributes a) throws IOException {
|
||||
if ((Files.isRegularFile(p) && pathMatcher.matches(p.getFileName()))) {
|
||||
if (Files.getLastModifiedTime(p).toInstant().isBefore(instant)) {
|
||||
Files.delete(p);
|
||||
}
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue