fixed issue returning dirs

This commit is contained in:
Mark Wolters 2024-04-05 13:53:33 -04:00 committed by Jonathan Shook
parent e14761bb08
commit 3845fd8256

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.nio.file.FileSystem;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.security.MessageDigest; import java.security.MessageDigest;
@ -129,7 +130,7 @@ public class ResolverForNBIOCache implements ContentResolver {
logger.warn(() -> "Remote checksum file " + remoteChecksumFileStr + " does not exist"); logger.warn(() -> "Remote checksum file " + remoteChecksumFileStr + " does not exist");
return cachePath; return cachePath;
} else { } else {
Path checksumPath = Path.of(cachePath.toString().substring(0, cachePath.toString().indexOf('.')) + ".sha256"); Path checksumPath = Path.of(cachePath.toString().substring(0, cachePath.toString().lastIndexOf('.')) + ".sha256");
Files.writeString(checksumPath, localChecksumStr); Files.writeString(checksumPath, localChecksumStr);
logger.debug(() -> "Generated local checksum and saved to cache at " + checksumPath); logger.debug(() -> "Generated local checksum and saved to cache at " + checksumPath);
String remoteChecksum = new String(checksum.getInputStream().readAllBytes()); String remoteChecksum = new String(checksum.getInputStream().readAllBytes());
@ -181,7 +182,7 @@ public class ResolverForNBIOCache implements ContentResolver {
* 5. If checksums match return the local file * 5. If checksums match return the local file
* 6. If checksums do not match remove the local file and go to "File is not in cache" operations * 6. If checksums do not match remove the local file and go to "File is not in cache" operations
*/ */
Path checksumPath = Path.of(cachePath.toString().substring(0, cachePath.toString().indexOf('.')) + ".sha256"); Path checksumPath = Path.of(cachePath.toString().substring(0, cachePath.toString().lastIndexOf('.')) + ".sha256");
if (!Files.isReadable(checksumPath)) { if (!Files.isReadable(checksumPath)) {
try { try {
Files.writeString(checksumPath, generateSHA256Checksum(cachePath.toString())); Files.writeString(checksumPath, generateSHA256Checksum(cachePath.toString()));
@ -260,8 +261,8 @@ public class ResolverForNBIOCache implements ContentResolver {
public List<Path> resolveDirectory(URI uri) { public List<Path> resolveDirectory(URI uri) {
List<Path> dirs = new ArrayList<>(); List<Path> dirs = new ArrayList<>();
Path path = resolvePath(uri); Path path = Path.of(cache + uri.getPath());
if (path!=null && Files.isDirectory(path)) { if (Files.isDirectory(path)) {
dirs.add(path); dirs.add(path);
} }
return dirs; return dirs;