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

Use progress bar to show the progress of copying files #13

Merged
merged 1 commit into from
Nov 26, 2023

Conversation

andreiled
Copy link
Owner

@andreiled andreiled commented Nov 26, 2023

Fixes #11 - Use progress bar to show the progress of copying files from each recognized source directory

  1. Add a new dependency on the cli-progress library (Npm package).
  2. Add a new ProgressTracker and SingleDirBar classes
    wrapping the MultiBar and SingleBar classes from the cli-progress library respectively
    to encapsulate the minutia of managing a console progress bar away from the main Downloader class.
  3. Update the Downloader.downloadNewFilesFromDir method:
    • use ProgressTracker.startTracking before starting the loop over newFiles
      in order to create a new progress bar to track the progress of downloading new file
      from the current source directory
    • update the progress bar state with each copied file
    • use ProgressTracker.log instead of console.log and similar methods
      in order to avoid conflicts with running progress bars
    • use SingleDirBar.setStatusSummary to 'log' the two INFO messages
      about saving source directory cursor position (aka latest processed file)
      after downloading all new files from a given source directory
      in order to show the latest of the two to the right of the associated completed progress bar

Manual Testing

  1. Using a memory card that had a few new photos since the last time I downloaded photos from it using this tool.

  2. Manually update the cursor.json file on my memory card to roll it two files back in order to have the tool pick up the two most recently copied files as if they were new.

  3. Run the tool to copy new photos: npm run build && node dist

    • AR == ER: the output now contains a progress reflecting how many files were copied (as a number and as a percentage), what file is being copied at the moment and such.
    • AR == ER: the two warning messages about the two files being already present in the target location are shown above the progress bar and, more importantly, do not break the progress bar like a regular console.log would.

    image

…om each recognized source directory

1. Add a new dependency on the `cli-progress` library (Npm package).
2. Add a new `ProgressTracker` and `SingleDirBar` classes
   wrapping the `MultiBar` and `SingleBar` classes from the `cli-progress` library respectively
   to encapsulate the minutia of managing a console progress bar away from the main `Downloader` class.
3. Update the `Downloader.downloadNewFilesFromDir` method:
    - use `ProgressTracker.startTracking` before starting the loop over `newFiles`
      in order to create a new progress bar to track the progress of downloading new file
      from the current source directory
    - update the progress bar state with each copied file
    - use `ProgressTracker.log` instead of `console.log` and similar methods
      in order to avoid conflicts with running progress bars
    - use `SingleDirBar.setStatusSummary` to 'log' the two `INFO` messages
      about saving source directory cursor position (aka latest processed file)
      after downloading all new files from a given source directory
      in order to show the latest of the two to the right of the associated completed progress bar
@andreiled andreiled merged commit 77c166b into main Nov 26, 2023
2 checks passed
@andreiled andreiled deleted the feature/progress branch December 3, 2023 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant