Skip to content

Commit

Permalink
[RFR-1187] Fix upload crash without locations
Browse files Browse the repository at this point in the history
[RFR-1187] Fix upload crash without locations
  • Loading branch information
hb0 authored Oct 23, 2024
2 parents bd56316 + 7802aa0 commit 6be0e48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/de/cyface/uploader/model/Uploadable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ interface Uploadable {

fun measurementId(): Long

/**
* The Unix timestamp in milliseconds or `null` if no locations exist, which is legitimate [LEIP-1187].
*/
fun timestamp(): Long?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import java.io.Serializable
* @author Armin Schnabel
* @property length The length of the measurement in meters.
* @property locationCount The count of geolocations in the transmitted measurement.
* @property startLocation The first [GeoLocation] captured by the transmitted measurement.
* @property endLocation The last [GeoLocation] captured by the transmitted measurement.
* @property startLocation The first [GeoLocation] captured by the transmitted measurement, if available.
* @property endLocation The last [GeoLocation] captured by the transmitted measurement, if available.
* @property modality The modality type used to capture the measurement.
*/
data class MeasurementMetaData(
Expand All @@ -40,15 +40,11 @@ data class MeasurementMetaData(
val modality: String,
) : MetaData, Serializable {
init {
// A measurement _without_ locations (`startLocation=null`) _is_ legitimate, as we want the server
// to be able to decide if such measurements should be uploaded or not. [LEIP-1187]
if (locationCount < MINIMUM_LOCATION_COUNT) {
throw TooFewLocations("LocationCount smaller than required: $locationCount")
}
requireNotNull(startLocation) {
"Data incomplete startLocation was null!"
}
requireNotNull(endLocation) {
"Data incomplete endLocation was null!"
}
require(length >= MINIMUM_TRACK_LENGTH) {
"Field length had an invalid value smaller then 0.0: $length"
}
Expand Down

0 comments on commit 6be0e48

Please sign in to comment.