Skip to content

Commit

Permalink
[RFR-1170] Fix NPE during upload attempt
Browse files Browse the repository at this point in the history
[RFR-1170] Fix NPE during upload attempt
  • Loading branch information
hb0 authored Sep 26, 2024
2 parents 58b5cc6 + 0f06e34 commit 38a4610
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,7 @@ class SyncAdapter private constructor(
tracks.isEmpty() || (tracks[0].geoLocations.size > 0
&& tracks[tracks.size - 1].geoLocations.size > 0)
)
val lastTrack: List<ParcelableGeoLocation?>? =
if (tracks.isNotEmpty()) tracks[tracks.size - 1].geoLocations else null
val lastTrack = if (tracks.isNotEmpty()) tracks[tracks.size - 1].geoLocations else null
var startLocation: GeoLocation? = null
if (tracks.isNotEmpty()) {
val l = tracks[0].geoLocations[0]!!
Expand All @@ -641,7 +640,9 @@ class SyncAdapter private constructor(
}
val filesSize = if (allAttachments > 0) {
// TODO: support multiple attachments by zipping them
val attachment = persistence.attachmentDao!!.loadOneByMeasurementIdAndType(measurement.id, FileType.JSON)
// (!) we load the CSV file here as the location_metrics.csv should always exist
// if not, the upload crashes with an NPE.
val attachment = persistence.attachmentDao!!.loadOneByMeasurementIdAndType(measurement.id, FileType.CSV)
val folderPath = File(attachment!!.path.parent.toUri())
getFolderSize(folderPath)
} else 0
Expand Down

0 comments on commit 38a4610

Please sign in to comment.