Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc): delete many files #338

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/docs/index.html

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@ definitions:
required:
- ids
type: object
service.FileDeleteManyResult:
properties:
failed:
items:
type: string
type: array
succeeded:
items:
type: string
type: array
type: object
service.FileList:
properties:
data:
Expand Down Expand Up @@ -909,9 +920,7 @@ paths:
"200":
description: OK
schema:
items:
type: string
type: array
$ref: '#/definitions/service.FileDeleteManyResult'
"500":
description: Internal Server Error
schema:
Expand Down
2 changes: 1 addition & 1 deletion api/router/file_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func (r *FileRouter) DeleteOne(c *fiber.Ctx) error {
// @Id files_delete_many
// @Produce json
// @Param body body service.FileDeleteManyOptions true "Body"
// @Success 200 {array} string
// @Success 200 {object} service.FileDeleteManyResult
// @Failure 500 {object} errorpkg.ErrorResponse
// @Router /files [delete]
func (r *FileRouter) DeleteMany(c *fiber.Ctx) error {
Expand Down
5 changes: 4 additions & 1 deletion api/service/file_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,10 @@ type FileDeleteManyResult struct {
}

func (svc *FileService) DeleteMany(opts FileDeleteManyOptions, userID string) (*FileDeleteManyResult, error) {
res := &FileDeleteManyResult{}
res := &FileDeleteManyResult{
Failed: make([]string, 0),
Succeeded: make([]string, 0),
}
for _, id := range opts.IDs {
if err := svc.DeleteOne(id, userID); err != nil {
res.Failed = append(res.Failed, id)
Expand Down
7 changes: 6 additions & 1 deletion ui/src/client/api/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export type DeleteManyOptions = {
ids: string
}

export type DeleteManyResult = {
succeeded: string[]
failed: string[]
}

export type PatchNameOptions = {
name: string
}
Expand Down Expand Up @@ -325,7 +330,7 @@ export default class FileAPI {
url: `/files`,
method: 'DELETE',
body: JSON.stringify(options),
})
}) as Promise<DeleteManyResult>
}

static async moveOne(id: string, targetId: string) {
Expand Down
Loading