(objectRelativePaths []string)
| 98 | } |
| 99 | |
| 100 | func (f *Folder) DeleteObjects(objectRelativePaths []string) error { |
| 101 | if f.isVersioningEnabled() { |
| 102 | return fmt.Errorf("versioning is not supported for oss") |
| 103 | } |
| 104 | |
| 105 | for _, part := range partitionObjectKeys(objectRelativePaths, 1000) { |
| 106 | var objectsToDelete []oss.DeleteObject |
| 107 | for _, key := range part { |
| 108 | fullPath := f.GetPath() + key |
| 109 | tracelog.DebugLogger.Println("Deleting OSS object:", fullPath) |
| 110 | objectsToDelete = append(objectsToDelete, oss.DeleteObject{Key: oss.Ptr(fullPath)}) |
| 111 | } |
| 112 | |
| 113 | _, err := f.ossAPI.DeleteMultipleObjects(context.Background(), &oss.DeleteMultipleObjectsRequest{ |
| 114 | Bucket: oss.Ptr(f.bucket), |
| 115 | Objects: objectsToDelete, |
| 116 | }) |
| 117 | if err != nil { |
| 118 | return fmt.Errorf("failed to delete oss objects: %w", err) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | func partitionObjectKeys(keys []string, size int) [][]string { |
| 126 | if len(keys) == 0 { |
nothing calls this directly
no test coverage detected