summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNasser Grainawi <quic_nasserg@quicinc.com>2023-11-14 13:55:48 -0700
committerNasser Grainawi <quic_nasserg@quicinc.com>2024-02-19 23:31:34 +0000
commit426d67848a0e739d69f43098f46ee00b34fa7d77 (patch)
tree9ed1f5b7a335d0eec12c2347d975b6e0b9ee07b3
parent67142cacbbf47053b26e626036db97ce07cf1186 (diff)
downloadjgit-426d67848a0e739d69f43098f46ee00b34fa7d77.tar.gz
jgit-426d67848a0e739d69f43098f46ee00b34fa7d77.zip
storage.file: Do not throw NSFE when deleting tmp files
If we try to delete a tmp file and it already doesn't exist, then there's no problem and we don't need to throw an exception. This is especially true for these existing cases using FileUtils.RETRY because any missing files on retries are already considered successes. Not throwing the exception quiets some logs and improves overall exception handling. Change-Id: Ia6e06ba042c5920d5cd9f8db2e1d829affa3d796 Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LooseObjects.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java4
4 files changed, 8 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index 5409c4fca7..fc058abcca 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -1934,7 +1934,7 @@ public class GC {
token.close();
}
if (wasLocked) {
- FileUtils.delete(pidFile.toFile(), FileUtils.RETRY);
+ FileUtils.delete(pidFile.toFile(), FileUtils.RETRY | FileUtils.SKIP_MISSING);
}
} catch (IOException e) {
LOG.error(MessageFormat
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LooseObjects.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LooseObjects.java
index 87025b37f8..b4bb2a9293 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LooseObjects.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LooseObjects.java
@@ -282,7 +282,7 @@ class LooseObjects {
// that already exists. We can't be sure renameTo() would
// fail on all platforms if dst exists, so we check first.
//
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
return InsertLooseObjectResult.EXISTS_LOOSE;
}
@@ -300,7 +300,7 @@ class LooseObjects {
// Any other IO error is considered a failure.
//
LOG.error(e.getMessage(), e);
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
return InsertLooseObjectResult.FAILURE;
}
@@ -312,7 +312,7 @@ class LooseObjects {
// know what went wrong, so fail.
//
LOG.error(e.getMessage(), e);
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
return InsertLooseObjectResult.FAILURE;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 579f931795..9f21481a13 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -548,11 +548,11 @@ public class ObjectDirectory extends FileObjectDatabase {
// If the object is already in the repository, remove temporary file.
//
if (loose.hasCached(id)) {
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
return InsertLooseObjectResult.EXISTS_LOOSE;
}
if (!createDuplicate && has(id)) {
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
return InsertLooseObjectResult.EXISTS_PACKED;
}
return loose.insert(tmp, id);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
index 2f30a9797f..24fead86bd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
@@ -204,7 +204,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
return tmp;
} finally {
if (delete) {
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
}
}
}
@@ -232,7 +232,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
return tmp;
} finally {
if (delete) {
- FileUtils.delete(tmp, FileUtils.RETRY);
+ FileUtils.delete(tmp, FileUtils.RETRY | FileUtils.SKIP_MISSING);
}
}
}