Skip to content

Conversation

NikolasHaimerl
Copy link
Contributor

@NikolasHaimerl NikolasHaimerl commented May 21, 2025

Summary

This PR introduces the initial implementation of the PDP Checker tool for downloading files based on Content Identifiers (CIDs).

Changes

  1. Core Functionality:

    • Implemented retrieveFile for fetching files with retry logic.
  2. Testing:

    • Added unit and integration tests for retrieval and CID validation.

Closes #3

@NikolasHaimerl NikolasHaimerl marked this pull request as ready for review May 21, 2025 21:42
Copy link
Member

@pyropy pyropy left a comment

Choose a reason for hiding this comment

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

Awesome stuff, there's only few small things to take care of before we merge it.

lib/retrieval.js Outdated
@@ -0,0 +1,48 @@
import fetch from 'node-fetch'
Copy link
Member

Choose a reason for hiding this comment

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

There's no need for using node-fetch as fetch is part of the standard library for node versions 18+ (we're using 22).

@@ -0,0 +1,48 @@
import fetch from 'node-fetch'
import pRetry from 'p-retry'
Copy link
Member

Choose a reason for hiding this comment

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

It's aweesome that you've added p-retry 👍🏻

const testFilePath = path.join(__dirname, 'testData.pdf')
const testData = await fs.readFile(testFilePath)

const expectedHash = createHash('sha256').update(testData).digest('hex')
Copy link
Member

Choose a reason for hiding this comment

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

We can save expectedHash as a constant rather then computing it for every time we run this test. This could also enable us to remove the testData.pdf file from the repository.

@NikolasHaimerl NikolasHaimerl changed the title Nhaimerl poc pdp retrieval feat: poc pdp retrieval May 22, 2025
@NikolasHaimerl NikolasHaimerl marked this pull request as draft May 22, 2025 11:59
@NikolasHaimerl NikolasHaimerl requested a review from pyropy May 22, 2025 12:06
@bajtos bajtos removed their request for review June 2, 2025 09:13
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.

2 participants