Skip to content

Commit

Permalink
fix(b2): fix that downloaded file has 0 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Urban committed Aug 14, 2024
1 parent 7ba4522 commit d5a3d29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func NewB2Repo(opts options) (*b2repo, error) {
keyID: opts.B2KeyID,
region: opts.B2Region,
}

l.Verbosef("starting b2 client with %d connections to %s %s \n", r.concurrentUploads, r.endpoint, r.bucket)
client, err := b2.NewClient(r.ctx, r.keyID, r.appKey)

Expand Down Expand Up @@ -196,7 +196,6 @@ func (r *b2repo) Upload(path string, target string) error {
}

func (r *b2repo) Download(target string, path string) error {

file, err := os.Create(path)
if err != nil {
return fmt.Errorf("download error: %w", err)
Expand All @@ -205,10 +204,11 @@ func (r *b2repo) Download(target string, path string) error {

bucket := r.b2Bucket

remoteFile := bucket.Object(path).NewReader(r.ctx)
l.Infof("downloading %s from B2 bucket %s to %s\n", target, r.bucket, path)
remoteFile := bucket.Object(target).NewReader(r.ctx)
defer remoteFile.Close()

localFile, err := os.Create(target)
localFile, err := os.Create(path)
if err != nil {
return err
}
Expand Down

0 comments on commit d5a3d29

Please sign in to comment.