mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
refactor: improve progress bar logic and update display (#14)
* fix: Revise progress tracking mechanism * chore: remove unused getDependencies func * chore: removed unused property & add fetcher check * Update pkg/wrapper/npm_base.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com> * refactor: make SetProgressTracker common for all fetchers --------- Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
+12
-3
@@ -6,7 +6,9 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/safedep/pmg/internal/ui"
|
||||
"github.com/safedep/pmg/pkg/models"
|
||||
)
|
||||
|
||||
@@ -21,9 +23,11 @@ type Fetcher interface {
|
||||
|
||||
// BaseFetcher implements common functionality for all registry fetchers
|
||||
type BaseFetcher struct {
|
||||
visitedMu sync.RWMutex
|
||||
visited map[string]bool
|
||||
client RegistryClient
|
||||
visitedMu sync.RWMutex
|
||||
visited map[string]bool
|
||||
client RegistryClient
|
||||
progressTracker ui.ProgressTracker
|
||||
fetchedDeps int32
|
||||
}
|
||||
|
||||
// NewBaseFetcher creates a new BaseFetcher with the specified registry client
|
||||
@@ -34,6 +38,11 @@ func NewBaseFetcher(client RegistryClient) *BaseFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
func (bf *BaseFetcher) SetProgressTracker(tracker ui.ProgressTracker) {
|
||||
bf.progressTracker = tracker
|
||||
atomic.StoreInt32(&bf.fetchedDeps, 0)
|
||||
}
|
||||
|
||||
// isVisited checks if a package has already been visited
|
||||
func (bf *BaseFetcher) isVisited(key string) bool {
|
||||
bf.visitedMu.RLock()
|
||||
|
||||
Reference in New Issue
Block a user