GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.46k stars 1.13k forks source link

Include assets inside B/R #12627

Closed giohappy closed 1 month ago

giohappy commented 1 month ago

The assets (ASSETS_FOLDER) folder must be part of the B/R. The logic will be the same as for the media folder. DRY, transform the logic in a common method, bot for the backup and restore.

etj commented 1 month ago

Two more tasks here, that can be implemented later:

mattiagiupponi commented 1 month ago

Restoring assets_root will be done in the future, now it migh raise other issues related to the heuristic replace. A possible solution is to save the original .env file during the backup and access it during the restore. A possible heuristic solutions could be the following:

logger.info("*** Update Assets path...")
for instance in LocalAsset.objects.iterator():
    should_be_updated = any(settings.ASSETS_ROOT not in loc for loc in instance.location)
    if should_be_updated:
        new_assets = []
        for loc in instance.location:
            if settings.ASSETS_ROOT not in loc:
                new_assets.append(loc.replace(os.path.dirname(os.path.dirname(loc)), ttings.ASSETS_ROOT))
            else:
                new_assets.append(loc)
        instance.location = new_assets
        instance.save()
logger.info("*** Assets path updated...")