Skip to content

Commit

Permalink
fix a bug: lost data + dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
glin-gogogo committed Nov 26, 2024
1 parent 8233291 commit dbf85f2
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions scow/scow.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ func (c *client) DownloadFile(ctx context.Context, storageVolName, filePath stri
}

if !response.IsSuccess() {
if response.StatusCode() != http.StatusOK {
return nil, fmt.Errorf("http Code:%v, Status:%v", response.StatusCode(), response.Status())
}

r := &ErrorReply{}
err = json.Unmarshal(response.Body(), r)
if err != nil {
Expand Down Expand Up @@ -738,8 +742,15 @@ func (c *client) listDirObjs(ctx context.Context, storageVolName, dirPath string
timeObj = time.Time{}
}

key := path.Join(dirPath, item.Name)
if strings.ToUpper(item.Type) == types.StorageListTypeDir {
if !strings.HasSuffix(key, "/") {
key += "/"
}
}

objects = append(objects, &FileInfo{
Key: path.Join(dirPath, item.Name),
Key: key,
Size: item.Size,
LastModified: timeObj,
})
Expand Down Expand Up @@ -778,18 +789,14 @@ func (c *client) ListDirFiles(ctx context.Context, storageVolName, prefix string
}

if prefix != "" {
if !strings.HasSuffix(prefix, "/") {
prefix += "/"
}
resp = append(resp, &FileInfo{
Key: prefix,
})
}

//if !strings.HasSuffix(prefix, "/") {
// prefix += "/"
//}
//resp = append(resp, &FileInfo{
// Key: prefix,
//})

return resp, nil
}

Expand Down Expand Up @@ -1008,9 +1015,10 @@ func (c *client) uploadBigFile(ctx context.Context, storageVolName, filePath, di
return errors.New("Code:" + r.Code + ", Msg:" + r.Message)
}

if rc < types.ChunkSize {
break
}
// -fix bug
//if rc < types.ChunkSize {
// break
//}
}

//- merge file chunks
Expand Down

0 comments on commit dbf85f2

Please sign in to comment.