storage: file: De-duplicate File.exists()+File.isFile()

File.isFile() [1] checks if the file exists and is a normal file.

[1] https://docs.oracle.com/javase/8/docs/api/java/io/File.html#isFile--

Change-Id: I0a883f2482ecc5ac58b270351b416742b568eb68
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
This commit is contained in:
Nasser Grainawi 2021-12-03 10:05:53 -07:00 committed by Matthias Sohn
parent f829f5f838
commit 38db89142d
2 changed files with 2 additions and 2 deletions

View File

@ -184,7 +184,7 @@ public long getPackSize() {
String p = pack.getAbsolutePath();
String i = p.substring(0, p.length() - ".pack".length()) + ".idx"; //$NON-NLS-1$ //$NON-NLS-2$
File idx = new File(i);
if (idx.exists() && idx.isFile())
if (idx.isFile())
size += idx.length();
return size;
}

View File

@ -1110,7 +1110,7 @@ LooseRef scanRef(LooseRef ref, String name) throws IOException {
try {
buf = IO.readSome(path, limit);
} catch (FileNotFoundException noFile) {
if (path.exists() && path.isFile()) {
if (path.isFile()) {
throw noFile;
}
return null; // doesn't exist or no file; not a reference.