Move SSD truth timestamp fallback to typed Kotlin
ober
0de4bea013bccd820feca7c4add801e9e1b4378e
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -1764,7 +1764,7 @@ textUtf8Bytes textUtf8SizeBytes textUtf8BytesWithinLimit nullableTextPresent nullableTextOrEmpty nullableTextOrDefault nullableByteCountPresent nullableByteCountOrZero - nullableByteCountWithinLimit + nullableByteCountOrDefault nullableByteCountWithinLimit oldDestinationBytes urlEffectivePort constantTimeBytesEqual constantTimeBytesMismatch constantTimeNullableBytesEqual constantTimeNullableBytesMismatch @@ -1895,6 +1895,8 @@ (not (nullable-null? bytes))) (def (nullableByteCountOrZero (bytes : (Nullable Int))) : Int (if (nullable-null? bytes) (int 0) (nullable-get bytes))) + (def (nullableByteCountOrDefault (bytes : (Nullable Int)) (fallback : Int)) : Int + (if (nullable-null? bytes) fallback (nullable-get bytes))) (def (nullableByteCountWithinLimit (bytes : (Nullable Int)) (maxBytes : Int)) : Bool (byteCountWithinLimit (nullableByteCountOrZero bytes) maxBytes)) @@ -8611,7 +8613,7 @@ " if (fileIsNotRegular(file)) return null" " return try {" " val truth = jsonObjectFromText(readLocalText(file))" - " truthIndexEntryFromJson(file, truth, truthTime(truth) ?: file.lastModified())" + " truthIndexEntryFromJson(file, truth, nullableByteCountOrDefault(truthTime(truth), file.lastModified()))" " } catch (_: Exception) {" " null" " }"