lint fixes (#14)
* lint fixes Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -3,13 +3,12 @@ package file
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/unistack-org/micro/v3/client"
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
proto "github.com/unistack-org/micro/v3/util/file/proto"
|
||||
)
|
||||
|
||||
@@ -156,7 +155,7 @@ func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
return err
|
||||
}
|
||||
if stat.Type == "Directory" {
|
||||
return errors.New(fmt.Sprintf("%s is directory.", filename))
|
||||
return fmt.Errorf("%s is directory.", filename)
|
||||
}
|
||||
|
||||
blocks := int(stat.Size / blockSize)
|
||||
@@ -164,7 +163,7 @@ func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
blocks += 1
|
||||
}
|
||||
|
||||
log.Printf("Download %s in %d blocks\n", filename, blocks-blockId)
|
||||
logger.Infof("Download %s in %d blocks", filename, blocks-blockId)
|
||||
|
||||
file, err := os.OpenFile(saveFile, os.O_CREATE|os.O_WRONLY, 0666)
|
||||
if err != nil {
|
||||
@@ -187,14 +186,14 @@ func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
}
|
||||
|
||||
if i%((blocks-blockId)/100+1) == 0 {
|
||||
log.Printf("Downloading %s [%d/%d] blocks", filename, i-blockId+1, blocks-blockId)
|
||||
logger.Infof("Downloading %s [%d/%d] blocks", filename, i-blockId+1, blocks-blockId)
|
||||
}
|
||||
|
||||
if rerr == io.EOF {
|
||||
break
|
||||
}
|
||||
}
|
||||
log.Printf("Download %s completed", filename)
|
||||
logger.Infof("Download %s completed", filename)
|
||||
|
||||
c.Close(sessionId)
|
||||
|
||||
|
@@ -37,7 +37,7 @@ func (h *handler) Open(ctx context.Context, req *proto.OpenRequest, rsp *proto.O
|
||||
path := filepath.Join(h.readDir, req.Filename)
|
||||
flags := os.O_CREATE | os.O_RDWR
|
||||
if req.GetTruncate() {
|
||||
flags = flags | os.O_TRUNC
|
||||
flags |= os.O_TRUNC
|
||||
}
|
||||
file, err := os.OpenFile(path, flags, 0666)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user