Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 3e2d4a1

Browse files
committed
s3_management: compute checksum in cloud
I.e. file never gets downloaded on the client, which is a nice thing
1 parent 2a7b17d commit 3e2d4a1

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

s3_management/manage.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import dataclasses
77
import functools
88
import time
9-
import hashlib
109

1110
from os import path, makedirs
1211
from datetime import datetime
@@ -363,12 +362,8 @@ def compute_sha256(self) -> None:
363362
for obj in self.objects:
364363
if obj.checksum is not None:
365364
continue
366-
print(f"Computing sha256 for {obj.orig_key} of size {obj.size}")
367-
sha256_sum = hashlib.sha256()
365+
print(f"Updating {obj.orig_key} of size {obj.size} with SHA256 checksum")
368366
s3_obj = BUCKET.Object(key=obj.orig_key)
369-
sha256_sum.update(s3_obj.get()["Body"].read())
370-
digest = sha256_sum.hexdigest()
371-
s3_obj.metadata.update({"checksum-sha256": digest})
372367
s3_obj.copy_from(CopySource={"Bucket": BUCKET.name, "Key": obj.orig_key},
373368
Metadata=s3_obj.metadata, MetadataDirective="REPLACE",
374369
ACL="public-read",

0 commit comments

Comments
 (0)