Browse Source

Merge branch 'stable-4.9' into stable-4.10

* stable-4.9:
  Ensure DirectoryStream is closed promptly

Change-Id: I62674a1db9266c04fb353ab697e2c0a24a7369b7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.10
Matthias Sohn 7 years ago
parent
commit
e512d919ec
  1. 26
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

26
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

@ -967,19 +967,19 @@ public class GC {
private void deleteTempPacksIdx() { private void deleteTempPacksIdx() {
Path packDir = repo.getObjectDatabase().getPackDirectory().toPath(); Path packDir = repo.getObjectDatabase().getPackDirectory().toPath();
Instant threshold = Instant.now().minus(1, ChronoUnit.DAYS); Instant threshold = Instant.now().minus(1, ChronoUnit.DAYS);
try { try (DirectoryStream<Path> stream =
Files.newDirectoryStream(packDir, "gc_*_tmp") //$NON-NLS-1$ Files.newDirectoryStream(packDir, "gc_*_tmp")) { //$NON-NLS-1$
.forEach(t -> { stream.forEach(t -> {
try { try {
Instant lastModified = Files.getLastModifiedTime(t) Instant lastModified = Files.getLastModifiedTime(t)
.toInstant(); .toInstant();
if (lastModified.isBefore(threshold)) { if (lastModified.isBefore(threshold)) {
Files.deleteIfExists(t); Files.deleteIfExists(t);
} }
} catch (IOException e) { } catch (IOException e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
} }
}); });
} catch (IOException e) { } catch (IOException e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
} }

Loading…
Cancel
Save