Skip to content

Commit 43a6313

Browse files
author
wcr
committed
better chunk put 时,删除原数据时,list找不到时,不应该直接抛异常,而是不走删除流程
1 parent 4d9a074 commit 43a6313

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

backend/better_chunk/chunker.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,22 +308,22 @@ func (f Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ..
308308
dir = ""
309309
}
310310
entries, err := f.FileStructure.List(ctx, dir)
311-
if err != nil {
312-
return nil, err
313-
}
314-
for _, entry := range entries {
315-
object, ok := entry.(fs.Object)
316-
if ok {
317-
suffix := strings.HasSuffix(object.Remote(), "¥}"+path.Base(src.Remote()))
318-
if suffix {
319-
err := object.Remove(ctx)
320-
if err != nil {
321-
return nil, err
311+
if err == nil {
312+
for _, entry := range entries {
313+
object, ok := entry.(fs.Object)
314+
if ok {
315+
suffix := strings.HasSuffix(object.Remote(), "¥}"+path.Base(src.Remote()))
316+
if suffix {
317+
err := object.Remove(ctx)
318+
if err != nil {
319+
return nil, err
320+
}
322321
}
323322
}
324-
}
325323

324+
}
326325
}
326+
327327
structureObject, err := f.FileStructure.Put(ctx, bytes.NewReader(chunkFileJson), NewObjectInfoWrapper(src, chunkRemote, int64(len(chunkFileJson))))
328328
if err != nil {
329329
return nil, err

0 commit comments

Comments
 (0)