diff --git a/docs/config/storage.md b/docs/config/storage.md index c258088d..d0064e27 100644 --- a/docs/config/storage.md +++ b/docs/config/storage.md @@ -58,4 +58,6 @@ STORAGES = { } ``` +In order to store old versions of a layer, the versioning should be activated in the bucket. + See more about the configuration on the [django-storages documentation](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html). diff --git a/umap/storage.py b/umap/storage.py index c03d4ccb..677bf7de 100644 --- a/umap/storage.py +++ b/umap/storage.py @@ -7,7 +7,6 @@ from pathlib import Path from botocore.exceptions import ClientError from django.conf import settings from django.contrib.staticfiles.storage import ManifestStaticFilesStorage -from django.core.files.base import File from django.core.files.storage import FileSystemStorage from rcssmin import cssmin from rjsmin import jsmin @@ -77,7 +76,8 @@ class UmapS3(S3Storage): metadata = self.connection.meta.client.head_object( Bucket=self.bucket_name, Key=instance.geojson.name ) - return metadata["VersionId"] + # Do not fail if bucket does not handle versioning + return metadata.get("VersionId", metadata["ETag"]) def make_filename(self, instance): return f"{str(instance.pk)}.geojson"