diff options
-rw-r--r-- | fietsboek/actions.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/fietsboek/actions.py b/fietsboek/actions.py index a5ba8a0..4974a2c 100644 --- a/fietsboek/actions.py +++ b/fietsboek/actions.py @@ -81,10 +81,6 @@ def add_track( dbsession.add(track) dbsession.flush() - # Best time to build the cache is right after the upload - track.ensure_cache(gpx_data) - dbsession.add(track.cache) - # Save the GPX data LOGGER.debug("Creating a new data folder for %d", track.id) manager = data_manager.initialize(track.id) @@ -99,6 +95,11 @@ def add_track( manager.compress_gpx(gpx.to_xml().encode("utf-8")) track.transformers = [[tfm.identifier(), tfm.parameters.dict()] for tfm in transformers] + # Best time to build the cache is right after the upload, but *after* the + # transformers have been applied! + track.ensure_cache(manager.decompress_gpx()) + dbsession.add(track.cache) + manager.engrave_metadata( title=track.title, description=track.description, @@ -205,3 +206,9 @@ def execute_transformers(request: Request, track: models.Track): LOGGER.debug("Saving new transformers on %d", track.id) track.transformers = serialized + + LOGGER.debug("Rebuilding cache for %d", track.id) + request.dbsession.delete(track.cache) + track.cache = None + track.ensure_cache(manager.decompress_gpx()) + request.dbsession.add(track.cache) |