Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1e9a26d98f
@ -51,7 +51,26 @@ class ImageEndpoint:
|
||||
@staticmethod
|
||||
@api_view(['GET'])
|
||||
def image_api_get_status(request, identifier):
|
||||
# TODO MARTIN
|
||||
# get metadata from MongoDB
|
||||
metadata = MongoDBService.getSingle(identifier)
|
||||
if not metadata:
|
||||
return JsonResponse({'valid': False, 'available': False})
|
||||
|
||||
# get stored SHA512 hash
|
||||
stored_hash = metadata.get('sha512', '')
|
||||
no_image = True
|
||||
|
||||
for service in ImageEndpoint.storageServiceList:
|
||||
service_image_bytes = service.read_file(metadata['filename'])
|
||||
if service_image_bytes is not None:
|
||||
no_image = False
|
||||
actual_service_hash = create_sha512(service_image_bytes)
|
||||
if stored_hash != actual_service_hash:
|
||||
return JsonResponse({'valid': False, 'available': True})
|
||||
|
||||
if no_image:
|
||||
JsonResponse({'valid': False, 'available': False})
|
||||
|
||||
return JsonResponse({'valid': True, 'available': True})
|
||||
|
||||
@staticmethod
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user