Fix hashDirectory for non-existent directories

This commit is contained in:
Jason Penilla 2022-09-23 20:15:05 -07:00
parent debc31e544
commit aa8744b450

View file

@ -72,8 +72,12 @@ fun hashFiles(files: List<Path>): String = files.asSequence()
"${it.fileName.pathString}:${it.sha256asHex()}"
}
fun hashDirectory(dir: Path): String =
Files.walk(dir).use { stream -> hashFiles(stream.filter { it.isRegularFile() }.collect(Collectors.toList())) }
fun hashDirectory(dir: Path): String {
if (!dir.isDirectory()) {
return ""
}
return Files.walk(dir).use { stream -> hashFiles(stream.filter { it.isRegularFile() }.collect(Collectors.toList())) }
}
fun DownloadService.download(
downloadName: String,