Skip to content
Snippets Groups Projects
Commit 7855358d authored by Jenkins for Software Heritage's avatar Jenkins for Software Heritage
Browse files

New upstream version 1.4.4

parents cdeccf97 0a10ac37
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 2.1
Name: swh.deposit
Version: 1.4.3
Version: 1.4.4
Summary: Software Heritage Deposit Server
Home-page: https://forge.softwareheritage.org/source/swh-deposit/
Author: Software Heritage developers
......
......@@ -44,3 +44,9 @@ ignore_missing_imports = True
[mypy-swh.storage.*]
ignore_missing_imports = True
[mypy-storages.*]
ignore_missing_imports = True
[mypy-azure.*]
ignore_missing_imports = True
Metadata-Version: 2.1
Name: swh.deposit
Version: 1.4.3
Version: 1.4.4
Summary: Software Heritage Deposit Server
Home-page: https://forge.softwareheritage.org/source/swh-deposit/
Author: Software Heritage developers
......
......@@ -125,6 +125,11 @@ class APIChecks(APIPrivateView, APIGet, DepositReadMixin):
# Use python's File api which is consistent across different types of
# storage backends (e.g. file, azure, ...)
# I did not find any other) workaround for azure blobstorage use, noop
# otherwise
reset_content_settings_if_needed(archive)
# FIXME: ^ Implement a better way (after digging into django-storages[azure]
with archive.open("rb") as archive_fp:
try:
with zipfile.ZipFile(archive_fp) as zip_fp:
......@@ -214,3 +219,35 @@ class APIChecks(APIPrivateView, APIGet, DepositReadMixin):
deposit.save()
return status.HTTP_200_OK, response, "application/json"
def reset_content_settings_if_needed(archive) -> None:
"""This resets the content_settings on the associated blob stored in an azure
blobstorage. This prevents the correct reading of the file and failing the checks
for no good reason.
"""
try:
from storages.backends.azure_storage import AzureStorage
except ImportError:
return None
if not isinstance(archive.storage, AzureStorage):
return None
from azure.storage.blob import ContentSettings
blob_client = archive.storage.client.get_blob_client(archive.name)
# Get the existing blob properties
properties = blob_client.get_blob_properties()
# reset content encoding in the settings
content_settings = dict(properties.content_settings)
content_settings["content_encoding"] = ""
# Set the content_type and content_language headers, and populate the remaining
# headers from the existing properties
blob_headers = ContentSettings(**content_settings)
blob_client.set_http_headers(blob_headers)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment