diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-02-15 23:27:30 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-02-15 23:27:30 +0100 |
commit | 413ac5ca31dcc3ccb84484748337b815599fe314 (patch) | |
tree | b89a170e87817d2e630e0d3e852d18308a7c0bbf | |
parent | c79802acda75e5e7e26c45a3a4d9da6b51da9215 (diff) | |
download | fietsboek-413ac5ca31dcc3ccb84484748337b815599fe314.tar.gz fietsboek-413ac5ca31dcc3ccb84484748337b815599fe314.tar.bz2 fietsboek-413ac5ca31dcc3ccb84484748337b815599fe314.zip |
properly rebuild cache after changing transformers
-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) |