This commit is contained in:
Chris Lu 2019-12-02 20:49:58 -08:00
parent 6383b45bd0
commit 70648d35ad
4 changed files with 12 additions and 12 deletions

View File

@ -12,8 +12,8 @@ func TestJsonpMarshalUnmarshal(t *testing.T) {
tv := &volume_server_pb.RemoteFile{
BackendType: "aws",
BackendId: "",
FileSize: 12,
BackendId: "",
FileSize: 12,
}
m := jsonpb.Marshaler{

View File

@ -135,7 +135,7 @@ func copyDatToRemoteTier(ctx context.Context, grpcDialOption grpc.DialOption, wr
}
}
processingSpeed := float64(resp.Processed - lastProcessed)/1024.0/1024.0
processingSpeed := float64(resp.Processed-lastProcessed) / 1024.0 / 1024.0
fmt.Fprintf(writer, "copied %.2f%%, %d bytes, %.2fMB/s\n", resp.ProcessedPercentage, resp.Processed, processingSpeed)

View File

@ -142,13 +142,13 @@ func (s3backendStorageFile S3BackendStorageFile) GetStat() (datSize int64, modTi
files := s3backendStorageFile.tierInfo.GetFiles()
if len(files)==0 {
if len(files) == 0 {
err = fmt.Errorf("remote file info not found")
return
}
datSize = int64(files[0].FileSize)
modTime = time.Unix(int64(files[0].ModifiedTime),0)
modTime = time.Unix(int64(files[0].ModifiedTime), 0)
return
}

View File

@ -12,7 +12,7 @@ import (
)
func uploadToS3(sess s3iface.S3API, filename string, destBucket string, destKey string,
fn func(progressed int64, percentage float32)error) (fileSize int64, err error) {
fn func(progressed int64, percentage float32) error) (fileSize int64, err error) {
//open the file
f, err := os.Open(filename)
@ -40,10 +40,10 @@ func uploadToS3(sess s3iface.S3API, filename string, destBucket string, destKey
})
fileReader := &s3UploadProgressedReader{
fp: f,
size:fileSize,
read:-fileSize,
fn:fn,
fp: f,
size: fileSize,
read: -fileSize,
fn: fn,
}
// Upload the file to S3.
@ -71,8 +71,9 @@ type s3UploadProgressedReader struct {
fp *os.File
size int64
read int64
fn func(progressed int64, percentage float32)error
fn func(progressed int64, percentage float32) error
}
func (r *s3UploadProgressedReader) Read(p []byte) (int, error) {
return r.fp.Read(p)
}
@ -96,7 +97,6 @@ func (r *s3UploadProgressedReader) ReadAt(p []byte, off int64) (int, error) {
return n, err
}
func (r *s3UploadProgressedReader) Seek(offset int64, whence int) (int64, error) {
return r.fp.Seek(offset, whence)
}