diff --git a/pkg/downloader/write_at.go b/pkg/downloader/write_at.go index d64b66a..e82e499 100644 --- a/pkg/downloader/write_at.go +++ b/pkg/downloader/write_at.go @@ -3,15 +3,20 @@ package downloader import ( "github.com/jedib0t/go-pretty/v6/progress" "os" + "sync" ) // writeAt wrapper for file to use progress bar type writeAt struct { + mu sync.Mutex f *os.File tracker *progress.Tracker } func (w *writeAt) WriteAt(p []byte, off int64) (int, error) { + w.mu.Lock() + defer w.mu.Unlock() + at, err := w.f.WriteAt(p, off) if err != nil { w.tracker.MarkAsErrored()