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:
parent
f829f5f838
commit
38db89142d
|
@ -184,7 +184,7 @@ public long getPackSize() {
|
||||||
String p = pack.getAbsolutePath();
|
String p = pack.getAbsolutePath();
|
||||||
String i = p.substring(0, p.length() - ".pack".length()) + ".idx"; //$NON-NLS-1$ //$NON-NLS-2$
|
String i = p.substring(0, p.length() - ".pack".length()) + ".idx"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
File idx = new File(i);
|
File idx = new File(i);
|
||||||
if (idx.exists() && idx.isFile())
|
if (idx.isFile())
|
||||||
size += idx.length();
|
size += idx.length();
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1110,7 +1110,7 @@ LooseRef scanRef(LooseRef ref, String name) throws IOException {
|
||||||
try {
|
try {
|
||||||
buf = IO.readSome(path, limit);
|
buf = IO.readSome(path, limit);
|
||||||
} catch (FileNotFoundException noFile) {
|
} catch (FileNotFoundException noFile) {
|
||||||
if (path.exists() && path.isFile()) {
|
if (path.isFile()) {
|
||||||
throw noFile;
|
throw noFile;
|
||||||
}
|
}
|
||||||
return null; // doesn't exist or no file; not a reference.
|
return null; // doesn't exist or no file; not a reference.
|
||||||
|
|
Loading…
Reference in New Issue