-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add SHA-1 idempotency primitives for CoreFileObject #963
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
Open
minitriga
wants to merge
21
commits into
stable
Choose a base branch
from
feat/idempotent-file-ops
base: stable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0cd636f
feat(sdk): add sha1_of_source helper for checksum comparison
minitriga f199281
test(sdk): cover sha1_of_source BinaryIO position rewind from non-zer…
minitriga 1790610
feat(sdk): add UploadResult dataclass for idempotent uploads
minitriga 1c7978b
docs(sdk): clarify UploadResult.checksum None cases per review
minitriga 296fd5f
feat(sdk): add async matches_local_checksum to InfrahubNode
minitriga 702917f
refactor(sdk): apply Task 3 review feedback to matches_local_checksum
minitriga 12011d0
feat(sdk): add sync matches_local_checksum to InfrahubNodeSync
minitriga dfd3123
feat(sdk): add async upload_if_changed with SHA-1 idempotency
minitriga 78fd071
refactor(sdk): apply Task 5 review feedback to upload_if_changed
minitriga 8f8457e
feat(sdk): add sync upload_if_changed to InfrahubNodeSync
minitriga a3a5a6a
feat(sdk): add skip_if_unchanged to async download_file
minitriga 721ff33
fix(sdk): enforce unsaved-node check before skip_if_unchanged short-c…
minitriga 442fe0a
feat(sdk): add skip_if_unchanged to sync download_file
minitriga 1abc22f
docs(sdk): add changelog fragment for idempotent file operations
minitriga 0fdfc01
docs(sdk): clarify UploadResult.checksum docstring and add fixed frag…
minitriga 65f7c71
style(sdk): apply ruff format to new idempotent file operations
minitriga 4e2d5a9
refactor(sdk): rename UploadResult.uploaded to was_uploaded per review
minitriga 93fe705
test(sdk): drop tautological UploadResult frozen test per review
minitriga 18e1572
docs(sdk): rewrite unsaved-node fix fragment in user-impact terms
minitriga 9b8ebc1
test(sdk): add positive-path HTTP assertions to upload/download idemp…
minitriga 5269fb6
docs(sdk): clarify that idempotency checks use cached node checksum
minitriga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed `InfrahubNode.download_file(skip_if_unchanged=True)` silently returning `0` bytes-written on nodes that had never been saved. Previously, if the local file at `dest` happened to have the same SHA-1 as whatever was cached on the unsaved node's `checksum.value`, callers got back a success-looking `0` result instead of a clear failure — which could mask the fact that the node had no server counterpart at all. Calling `download_file` on an unsaved node now raises `ValueError` consistently, whether or not `skip_if_unchanged` is set. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Added SHA-1 idempotency primitives for `CoreFileObject` nodes: | ||
|
|
||
| - `InfrahubNode.matches_local_checksum(source)` / sync variant — compare a local `bytes | Path | BinaryIO` source against the node's server-stored checksum without invoking a transfer. | ||
| - `InfrahubNode.upload_if_changed(source, name=None)` / sync variant — stage + save only when the local source differs from the server, returning an `UploadResult(uploaded, checksum)` dataclass. | ||
| - `download_file(..., skip_if_unchanged=True)` — short-circuit the download when `dest` already exists on disk with a matching SHA-1. Returns `0` bytes written when skipped. | ||
|
|
||
| A shared `sha1_of_source` helper (streaming, 64 KiB chunks) centralises the hashing convention in `infrahub_sdk.file_handler`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if I'm wrong, but
skip_if_unchangeddid not exist before this PR. I still don't really understand what this is saying, but I don't think it can be "fixed" and reference a new kwarg