mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
Checking the number of bytes written to Mongo GridFS (#889)
* Checking the number of bytes written to Mongo GridFS * adding missing import * formatting imports
This commit is contained in:
committed by
Marwan Sulaiman
parent
b59bf896fc
commit
c6644f82f9
@@ -2,6 +2,7 @@ package mongo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/gomods/athens/pkg/errors"
|
||||
@@ -23,10 +24,14 @@ func (s *ModuleStore) Save(ctx context.Context, module, version string, mod []by
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
_, err = io.Copy(f, zip) // check number of bytes written?
|
||||
numBytesWritten, err := io.Copy(f, zip)
|
||||
if err != nil {
|
||||
return errors.E(op, err, errors.M(module), errors.V(version))
|
||||
}
|
||||
if numBytesWritten <= 0 {
|
||||
e := fmt.Errorf("copied %d bytes to Mongo GridFS", numBytesWritten)
|
||||
return errors.E(op, e, errors.M(module), errors.V(version))
|
||||
}
|
||||
|
||||
m := &storage.Module{
|
||||
Module: module,
|
||||
|
||||
Reference in New Issue
Block a user