Skip to content

Commit

Permalink
Merge pull request #373 from 0xff-dev/main
Browse files Browse the repository at this point in the history
fix: delete model files when model got deleted
  • Loading branch information
bjwswang authored Dec 14, 2023
2 parents 5f5cb2d + 7c54031 commit b9bed4d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/datasource/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,22 @@ func (oss *OSS) Stat(ctx context.Context, info any) error {
return oss.statObject(ctx, ossInfo)
}

// TODO: implement `Remove` against info
func (oss *OSS) Remove(ctx context.Context, info any) error {
ossInfo, err := oss.preCheck(info)
if err != nil {
return err
}
if strings.HasSuffix(ossInfo.Object, "/") {
var resultErr error
for e := range oss.Client.RemoveObjects(
ctx,
ossInfo.Bucket,
oss.Client.ListObjects(ctx, ossInfo.Bucket, minio.ListObjectsOptions{Prefix: ossInfo.Object, Recursive: true}),
minio.RemoveObjectsOptions{}) {
resultErr = e.Err
}
return resultErr
}

return oss.Client.RemoveObject(ctx, ossInfo.Bucket, ossInfo.Object, minio.RemoveObjectOptions{ForceDelete: true})
}
Expand Down

0 comments on commit b9bed4d

Please sign in to comment.