fix(scan): uploads carry their sha256, so change detection compares the bytes (#531)
This commit was merged in pull request #531.
This commit is contained in:
1 parent
90c19b5a94
commit
a22b4497a5
8 files changed
+322
-11
No files matched your search
@@ -649,6 +649,14 @@ pub async fn upload_artifact(
|
||||
// add-artifact endpoint, not upload.
|
||||
let mut artifact = uploaded_artifact(kind, plc_format, &filename, &upload.path, upload.size)
|
||||
.ok_or(StatusCode::BAD_REQUEST)?;
|
||||
// What a scheduled scan compares to tell this upload from the files its
|
||||
// last scan read (#465): without it, no upload was ever known unchanged.
|
||||
let path = upload.path.clone();
|
||||
let (sha, _) = tokio::task::spawn_blocking(move || crate::ingest::blob::hash_file(&path))
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
artifact.content_hash = Some(sha);
|
||||
if kind != ArtifactKind::FirmwareImage {
|
||||
match archive_check(upload.path.clone()).await? {
|
||||
// 7z and rar are never unpacked: say so now, not after a scan.
|
||||
|
||||
Reference in new issue
Block a user