fix(fs): fix issues related to closing fd

This commit is contained in:
hexxa 2021-09-14 22:47:00 +08:00 committed by Hexxa
parent 70dda37c54
commit 5e8567d470
8 changed files with 120 additions and 105 deletions

View file

@ -575,7 +575,7 @@ func TestFileHandlers(t *testing.T) {
// cl := client.NewFilesClient(addr)
files := map[string]string{
"qs/files/uploadings/path1/f1": "12345678",
"qs/files/uploadings1/path1/f1": "12345678",
}
for filePath, content := range files {
@ -594,18 +594,13 @@ func TestFileHandlers(t *testing.T) {
offset := int64(0)
for _, chunk := range chunks {
base64Content := base64.StdEncoding.EncodeToString(chunk)
res, _, errs = cl.UploadChunk(filePath, base64Content, offset)
res, bodyStr, errs := cl.UploadChunk(filePath, base64Content, offset)
offset += int64(len(chunk))
if len(errs) > 0 {
t.Fatal(errs)
} else if res.StatusCode != 200 {
t.Fatal(res.StatusCode)
}
err = fs.Close()
if err != nil {
t.Fatal(err)
t.Fatal(fmt.Sprintln(res.StatusCode, bodyStr))
}
}
@ -663,11 +658,6 @@ func TestFileHandlers(t *testing.T) {
} else if res.StatusCode != 200 {
t.Fatal(res.StatusCode)
}
err = fs.Close()
if err != nil {
t.Fatal(err)
}
}
err = fs.Sync()