Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api and data version hashes #334

Closed
wants to merge 13 commits into from

Conversation

Sturlen
Copy link
Contributor

@Sturlen Sturlen commented Oct 11, 2023

As discussed on Discord. Walks and hashes the contents of the API and data folders on startup. I believe this to be more accurate than relying on git commit hashes. This is intended to replace /manifest as the way to notify a client about changes.
image

Copy link
Collaborator

@augustjohnson augustjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this is way better than the janky non-functional thing that I had, but it doesn't tie back to a git commit. Any chance we could add a git commit hash, and maybe a build ID into this endpoint?

Copy link
Collaborator

@augustjohnson augustjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok you have some issues here.

First you're calling your variable SHAhash even though it's not using SHA.

Second, md5 shouldn't be used really ever. I'd suggest replacing all usage with SHA256, or maybe using the hashlib.file_digest feature, which may speed some things up, but I would guess this is already snappy.

Third, I believe your with open statement could be simplified and clarified to:
digest=hashlib.sha256()
loop through files here:
with open(filepath, 'rb') as f1:
digest = hashlib.file_digest(f1,digest,"sha256")

return digest

@Sturlen
Copy link
Contributor Author

Sturlen commented Oct 12, 2023

Any chance we could add a git commit hash, and maybe a build ID into this endpoint?

Git commit is in now. where would you get a build ID from, and what purpose would it serve?

@Sturlen Sturlen requested a review from augustjohnson October 12, 2023 07:24
Copy link
Collaborator

@augustjohnson augustjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think subprocess git will work in production, the python alpine image does not include (and should not include) git.
Let's set aside the git commit info. The rest is great.

@augustjohnson augustjohnson changed the base branch from api_import_adjust to staging October 25, 2023 10:23
@augustjohnson augustjohnson changed the base branch from staging to release/1.4.0 November 7, 2023 13:14
@augustjohnson augustjohnson changed the base branch from release/1.4.0 to staging November 7, 2023 13:14
@augustjohnson augustjohnson changed the base branch from staging to release/1.4.0 November 7, 2023 18:42
@augustjohnson
Copy link
Collaborator

I have included this in the branch release/1.4.0

@augustjohnson
Copy link
Collaborator

Available here.
https://api-beta.open5e.com/version/

@Sturlen Sturlen deleted the api_versioning branch December 6, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants