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{ tv := &volume_server_pb.RemoteFile{
BackendType: "aws", BackendType: "aws",
BackendId: "", BackendId: "",
FileSize: 12, FileSize: 12,
} }
m := jsonpb.Marshaler{ 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) 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() files := s3backendStorageFile.tierInfo.GetFiles()
if len(files)==0 { if len(files) == 0 {
err = fmt.Errorf("remote file info not found") err = fmt.Errorf("remote file info not found")
return return
} }
datSize = int64(files[0].FileSize) datSize = int64(files[0].FileSize)
modTime = time.Unix(int64(files[0].ModifiedTime),0) modTime = time.Unix(int64(files[0].ModifiedTime), 0)
return return
} }

View file

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