(c *gin.Context)
| 366 | ) |
| 367 | |
| 368 | func (s *BatchFileService) Delete(c *gin.Context) error { |
| 369 | dep := dependency.FromContext(c) |
| 370 | fileClient := dep.FileClient() |
| 371 | |
| 372 | ctx := context.WithValue(c, inventory.LoadFileEntity{}, true) |
| 373 | files, _, err := fileClient.GetByIDs(ctx, s.IDs, 0) |
| 374 | if err != nil { |
| 375 | return serializer.NewError(serializer.CodeDBError, "Failed to get files", err) |
| 376 | } |
| 377 | |
| 378 | fc, tx, ctx, err := inventory.WithTx(c, fileClient) |
| 379 | if err != nil { |
| 380 | return serializer.NewError(serializer.CodeDBError, "Failed to start transaction", err) |
| 381 | } |
| 382 | |
| 383 | _, diff, err := fc.Delete(ctx, files, nil) |
| 384 | if err != nil { |
| 385 | _ = inventory.Rollback(tx) |
| 386 | return serializer.NewError(serializer.CodeDBError, "Failed to delete files", err) |
| 387 | } |
| 388 | |
| 389 | tx.AppendStorageDiff(diff) |
| 390 | if err := inventory.CommitWithStorageDiff(ctx, tx, dep.Logger(), dep.UserClient()); err != nil { |
| 391 | return serializer.NewError(serializer.CodeDBError, "Failed to commit transaction", err) |
| 392 | } |
| 393 | |
| 394 | return nil |
| 395 | } |
| 396 | |
| 397 | const ( |
| 398 | entityUserCondition = "entity_user" |
nothing calls this directly
no test coverage detected