Skip to content

Commit

Permalink
Use google-crc32c (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
oittaa authored Mar 25, 2021
1 parent 24952df commit 73b1f79
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV HOST 0.0.0.0
# Python app installation
WORKDIR $APP_HOME
COPY . ./
RUN ./install.sh
RUN pip install .

ENTRYPOINT ["gcp-storage-emulator"]
CMD ["start"]
6 changes: 3 additions & 3 deletions gcp_storage_emulator/handlers/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datetime import datetime, timezone
from http import HTTPStatus

import crc32c
import google_crc32c
from gcp_storage_emulator.exceptions import Conflict, NotFound

logger = logging.getLogger("api.object")
Expand Down Expand Up @@ -61,8 +61,8 @@ def _handle_conflict(response, err):
def _crc32c(content):
if isinstance(content, str):
content = content.encode()
val = crc32c.crc32c(content)
return b64encode(val.to_bytes(4, byteorder="big")).decode("ascii")
val = google_crc32c.Checksum(content)
return b64encode(val.digest()).decode("ascii")


def _md5(content):
Expand Down
16 changes: 0 additions & 16 deletions install.sh

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"wheel",
],
install_requires=[
"crc32c==2.2",
"fs==2.4.12",
"google-crc32c==1.1.2",
],
python_requires=">=3.6",
)

0 comments on commit 73b1f79

Please sign in to comment.