Use typed file predicates in SSD storage stats
ober
9b794d1bd1fec371711042bfa29beca85d244dc1
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -1564,7 +1564,7 @@ TruthIndexEntry-sourceName TruthIndexEntry-canonicalSourceName TruthIndexEntry-page TruthIndexEntry-dpi TruthIndexEntry-groupCount TruthIndexEntry-truthTime betterTruthIndex - fileExists fileIsRegular destinationNewFileDelta + fileExists fileIsDirectory fileIsRegular destinationNewFileDelta oldDestinationBytes urlEffectivePort remoteBearerTokenPresent remoteBearerTokenValid remotePinPresent remotePinOrNull remotePinSha256Length @@ -1577,6 +1577,8 @@ (kotlin-member-call exists)) (extern (fileIsFile (file : File)) : Bool (kotlin-member-get isFile)) + (extern (fileIsDirectoryRaw (file : File)) : Bool + (kotlin-member-get isDirectory)) (extern (fileLength (file : File)) : Int (kotlin-member-call length)) (extern (bytesSize (bytes : Bytes)) : Int32 @@ -1614,6 +1616,8 @@ (TruthIndexEntry-truthTime current))))) (def (fileExists (file : File)) : Bool (fileExistsRaw file)) + (def (fileIsDirectory (file : File)) : Bool + (and (fileExists file) (fileIsDirectoryRaw file))) (def (fileIsRegular (file : File)) : Bool (and (fileExists file) (fileIsFile file))) (def (destinationNewFileDelta (destination : File)) : Int32 @@ -7996,9 +8000,9 @@ " fun walk(file: File, depth: Int) {" " if (depth > 32) throw IllegalStateException(\"Storage tree too deep\")" " if (Files.isSymbolicLink(file.toPath())) throw IllegalStateException(\"Storage symlink rejected\")" - " if (file.isDirectory) {" + " if (fileIsDirectory(file)) {" " file.listFiles()?.forEach { walk(it, depth + 1) }" - " } else if (file.isFile) {" + " } else if (fileIsRegular(file)) {" " stats.files += 1" " stats.bytes += file.length()" " if (stats.files > MAX_STORAGE_FILES || stats.bytes > MAX_STORAGE_BYTES) {"