Skip to content

Commit

Permalink
Do not put temp gpx files into gpx database
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-osm committed Sep 26, 2024
1 parent af053b3 commit a42f1f7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ package net.osmand.shared.gpx

import net.osmand.shared.io.KFile
import net.osmand.shared.routing.ColoringType
import net.osmand.shared.util.PlatformUtil

class GpxDataItem(
file: KFile
) : DataItem(file) {

private var analysis: GpxTrackAnalysis? = null

companion object {
fun isRegularTrack(file: KFile) = file.path().startsWith(PlatformUtil.getOsmAndContext().getGpxDir().path())
}

fun isRegularTrack() = Companion.isRegularTrack(file)

fun getAnalysis(): GpxTrackAnalysis? {
return analysis
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ object GpxDbHelper : GpxReaderAdapter {
return null
}
val item = dataItems[file]
if (GpxDbUtils.isAnalyseNeeded(item)) {
if (GpxDbUtils.isAnalyseNeeded(item) && GpxDataItem.isRegularTrack(file)) {
readGpxItem(file, item, callback)
}
return item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class GpxReader(private val adapter: GpxReaderAdapter)
if (gpxFile.error == null) {
val analyser = PlatformUtil.getOsmAndContext().getTrackPointsAnalyser()
updatedItem.setAnalysis(gpxFile.getAnalysis(file.lastModified(), null, null, analyser))
if (!updatedItem.isRegularTrack()) {
return updatedItem
}
val creationTime: Long = updatedItem.requireParameter(GpxParameter.FILE_CREATION_TIME)
if (creationTime <= 0) {
updatedItem.setParameter(GpxParameter.FILE_CREATION_TIME, GpxUtilities.getCreationTime(gpxFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ object GpxUtilities {
gpxFile.modifiedTime = file.lastModified()
gpxFile.pointsModifiedTime = gpxFile.modifiedTime
if (gpxFile.error != null) {
log.info("Error reading gpx ${gpxFile.path}")
log.info("Error reading gpx ${gpxFile.path}: ${gpxFile.error!!.message}")
}
gpxFile
} catch (e: IOException) {
Expand Down

0 comments on commit a42f1f7

Please sign in to comment.