-
Notifications
You must be signed in to change notification settings - Fork 256
CLDSRV-925: UploadPartCopy handle checksums #6188
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
Merged
bert-e
merged 11 commits into
development/9.4
from
improvement/CLDSRV-925-uploadpartcopy-checksums
Jul 1, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1295a6d
CLDSRV-925: fix UploadPart returns default checksums breaking SDK's t…
leif-scality 1d4b4d4
CLDSRV-925: CopyObject require REPLACE directive for in-place checksu…
leif-scality a3b92e5
CLDSRV-925: fix reject Parts missing a COMPOSITE checksum when required
leif-scality cc1e1e5
CLDSRV-925: extract computeChecksumFromDataLocator from CopyObject
leif-scality 01317ed
CLDSRV-925: add checksum to metadataStorePart
leif-scality 9725c85
CLDSRV-925: UploadPartCopy handle checksums
leif-scality 981b66e
CLDSRV-925: UploadPartCopy handle checksums functional tests
leif-scality 879d313
CLDSRV-925: UploadPartCopy don't compute checksums for external backe…
leif-scality e89bc47
CLDSRV-925: CompleteMPU don't require per-part checksums for external…
leif-scality 5cd6b29
CLDSRV-925: fix leaked metadataBackend.deleteObject override in unit …
leif-scality 4334419
CLDSRV-925: prettier format
leif-scality 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,89 @@ | ||
| const { PassThrough } = require('stream'); | ||
| const async = require('async'); | ||
| const { jsutil } = require('arsenal'); | ||
|
|
||
| const { data } = require('../../../data/wrapper'); | ||
| const ChecksumWritable = require('../../../auth/streamingV4/ChecksumWritable'); | ||
|
|
||
| /** | ||
| * Sequentially GET the ordered source `dataLocator` parts into a single | ||
| * readable stream, reading them in order through `data.get`. Returns the | ||
| * PassThrough immediately; consumers should pipe it onward and observe | ||
| * `error` for any read failure along the way. | ||
| * | ||
| * @param {Array} dataLocator - ordered source parts | ||
| * @param {object} log - request logger | ||
| * @return {PassThrough} | ||
| */ | ||
| function buildSourcePartsStream(dataLocator, log) { | ||
| const passthrough = new PassThrough(); | ||
| const wrapErr = (err, part) => | ||
| Object.assign(err, { | ||
| copyPart: { key: part.key, dataStoreName: part.dataStoreName, dataStoreType: part.dataStoreType }, | ||
| }); | ||
| async.eachSeries( | ||
| dataLocator, | ||
| (part, cb) => { | ||
| const done = jsutil.once(cb); | ||
| if (part.dataStoreType === 'azure') { | ||
| // Azure's data.get writes part bytes into the provided writable | ||
| // instead of returning a Readable. Pipe a per-part PassThrough | ||
| // into the master passthrough and use its 'end' as the completion | ||
| // signal — same pattern arsenal's data.copyObject uses. | ||
| const perPart = new PassThrough(); | ||
| perPart.once('error', err => done(wrapErr(err, part))); | ||
| perPart.once('end', () => done()); | ||
| perPart.pipe(passthrough, { end: false }); | ||
| return data.get(part, perPart, log, err => { | ||
| if (err) { | ||
| perPart.destroy(err); | ||
| done(wrapErr(err, part)); | ||
| } | ||
| }); | ||
| } | ||
| return data.get(part, null, log, (err, partStream) => { | ||
| if (err) { | ||
| return done(wrapErr(err, part)); | ||
| } | ||
| partStream.once('error', err => done(wrapErr(err, part))); | ||
| partStream.once('end', () => done()); | ||
| partStream.pipe(passthrough, { end: false }); | ||
| return undefined; | ||
| }); | ||
| }, | ||
Check noticeCode scanning / CodeQL Callback-style function (async migration) Note
This function uses a callback parameter ('cb'). Refactor to async/await.
|
||
| err => { | ||
| if (err) { | ||
| passthrough.destroy(err); | ||
| } else { | ||
| passthrough.end(); | ||
| } | ||
| }, | ||
| ); | ||
| return passthrough; | ||
| } | ||
|
|
||
| /** | ||
| * Compute the checksum of the (range-adjusted) source bytes by streaming them | ||
| * through a ChecksumWritable sink. An empty `dataLocator` ends the stream | ||
| * immediately, yielding the empty-input digest. | ||
| * | ||
| * @param {Array} dataLocator - ordered source parts | ||
| * @param {string} algorithm - lowercase checksum algorithm name | ||
| * @param {object} log - request logger | ||
| * @param {function} cb - cb(err, { algorithm, value }) | ||
| * @return {undefined} | ||
| */ | ||
| function computeChecksumFromDataLocator(dataLocator, algorithm, log, cb) { | ||
| const onceCb = jsutil.once(cb); | ||
| const sourceStream = buildSourcePartsStream(dataLocator || [], log); | ||
| const checksumSink = new ChecksumWritable(algorithm, log); | ||
| sourceStream.once('error', err => { | ||
| checksumSink.destroy(err); | ||
| onceCb(err); | ||
| }); | ||
| checksumSink.once('error', onceCb); | ||
| checksumSink.once('finish', () => onceCb(null, { algorithm, value: checksumSink.digest })); | ||
| sourceStream.pipe(checksumSink); | ||
| } | ||
Check noticeCode scanning / CodeQL Callback-style function (async migration) Note
This function uses a callback parameter ('cb'). Refactor to async/await.
|
||
|
leif-scality marked this conversation as resolved.
|
||
|
|
||
| module.exports = { buildSourcePartsStream, computeChecksumFromDataLocator }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.