Skip to content

Commit

Permalink
docs: better document deploy by checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
Ananias Carvalho authored and anancarv committed Sep 5, 2024
1 parent 6affc61 commit 79a9bd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,14 @@ artifact = art.artifacts.deploy("<LOCAL_FILE_LOCATION>", "<ARTIFACT_PATH_IN_ARTI
artifact = art.artifacts.deploy("<LOCAL_FILE_LOCATION>", "<ARTIFACT_PATH_IN_ARTIFACTORY>", checksum_enabled=True)
# artifact = art.artifacts.deploy("Desktop/myNewFile.txt", "my-repository/my/new/artifact/directory/file.txt", checksums=True)
```
Note: the performance might suffer when deploying artifacts with checksums enabled.
Deploy an artifact to the specified destination by checking if the artifact content already exists in Artifactory.

If Artifactory already contains a user-readable artifact with the same checksum the artifact content is copied over
to the new location and returns a response without requiring content transfer.

Otherwise, a 404 error is returned to indicate that content upload is expected in order to deploy the artifact.

**Note**: The performance might suffer when deploying artifacts with checksums enabled.

#### Download an artifact
```python
Expand Down
6 changes: 3 additions & 3 deletions pyartifactory/models/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def generate(cls, file_: Path) -> Checksums:
mapping: dict[str, Callable[[], Any]] = {"md5": hashlib.md5, "sha1": hashlib.sha1, "sha256": hashlib.sha256}
results = {}

for algorithm, hashing_function in mapping.items():
hasher = hashing_function()
with file_.absolute().open("rb") as fd:
with file_.absolute().open("rb") as fd:
for algorithm, hashing_function in mapping.items():
hasher = hashing_function()
buf = fd.read(block_size)
while len(buf) > 0:
hasher.update(buf)
Expand Down

0 comments on commit 79a9bd5

Please sign in to comment.