MCPcopy
hub / github.com/wal-g/wal-g / DeleteObjects

Method DeleteObjects

pkg/storages/oss/folder.go:100–123  ·  view source on GitHub ↗
(objectRelativePaths []string)

Source from the content-addressed store, hash-verified

98}
99
100func (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
125func partitionObjectKeys(keys []string, size int) [][]string {
126 if len(keys) == 0 {

Callers

nothing calls this directly

Calls 5

isVersioningEnabledMethod · 0.95
GetPathMethod · 0.95
partitionObjectKeysFunction · 0.85
ErrorfMethod · 0.80
PrintlnMethod · 0.80

Tested by

no test coverage detected