Skip to content

fixed downloadRange and downloadDiff#397

Merged
mafintosh merged 5 commits intomainfrom
fix-download-range-and-diff
Dec 23, 2025
Merged

fixed downloadRange and downloadDiff#397
mafintosh merged 5 commits intomainfrom
fix-download-range-and-diff

Conversation

@rafapaezbas
Copy link
Contributor

No description provided.

lib/download.js Outdated
super()

// it's a batch of downloads
if (Array.isArray(drive)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This works when combined with the if in _open, but it feels like a hack. It's not the fault of your PR, as I think you solved it in the simplest possible way given that downloadDiff creates a Download object with a completely different signature than expected.

Needs @mafintosh 's input before making any changes, but IMO we need an additional object which just manages a list of downloads and has a method to indicate when they're all done. Then downloadDiff can just return that directly, instead of passing through this object.


test.skip('drive.downloadRange(dbRanges, blobRanges)', async (t) => {
const { drive, swarm, mirror, corestore } = await testenv(t)
test('drive.downloadRange(dbRanges, blobRanges)', async (t) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The previous test was testing something else entirely it seems. Your test makes more sense to me, but needs a good look from @mafintosh too because we're changing both the tests and the main logic, which is always dangerous.

Likewise for the other test

index.js Outdated
for await (const entry of this.diff(length, folder, opts)) {
if (!entry.left) continue
const b = entry.left.value.blob
if (!entry.right) continue
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think your fix is correct, at least per what the README says, so you might be paving over another bug.

In drive.diff(version, folder), left is the entry in the current version, and right is the entry in the previous version (drive at length).

So logically, we want to download all blobs that are present in the current version (since those changed, as per the this.diff contract). This means we want to download all entries who have left set, which is what the previous code was doing.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeh reverted this after convo with rafa

@rafapaezbas rafapaezbas force-pushed the fix-download-range-and-diff branch from 1eb9dde to 0006f8a Compare December 22, 2025 10:21
@mafintosh mafintosh merged commit bfa9f59 into main Dec 23, 2025
5 checks passed
@mafintosh mafintosh deleted the fix-download-range-and-diff branch December 23, 2025 11:42
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.

3 participants