Skip to content
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

feat(hub): adding downloadFileToCacheDirWithProgress function #1334

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

axel7083
Copy link
Contributor

@axel7083 axel7083 commented Apr 2, 2025

Description

Related to #1331

To be able to offer a snapshotDownloadWithProgress method, similar to uploadFilesWithProgress the function called by snapshotDownload should also have a WithProgress version.

Splitting the downloadFileToCacheDir function

To avoid doing a big copy paste of the downloadFileToCacheDir function, I needed to split it.

  • Created type DownloadFileToCacheDirParams to avoid repeating the params everywhere
  • Created function preparePaths to determine the paths based on the params
  • Created function ensureDirectories to mkdir the directories
  • Created function prepareDownloadFileToCacheDir to handle all the functions above
  • Created function downloadAndStoreFile to do the heavy logic of downloading so downloadFileToCacheDir is simpler.

Those functions are exported, so downloadFileToCacheDirWithProgress can nicely use them

Testing

  • unit tests have been provided for downloadFileToCacheDirWithProgress

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.

1 participant