Skip to content

Commit

Permalink
some refactoring for checks
Browse files Browse the repository at this point in the history
should be roughly the same functions/usage as uploads
  • Loading branch information
odrling committed Apr 8, 2024
1 parent e9e84c8 commit 6726a51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions server/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ type CheckS3FileOutput struct {
Passed bool `json:"passed" example:"true" doc:"true if file passed all checks"`
}

func CheckS3File(ctx context.Context, kid uuid.UUID) (*CheckS3FileOutput, error) {
func CheckKara(ctx context.Context, kid uuid.UUID) (*CheckS3FileOutput, error) {
// TODO: find all related files to check
video_filename := filepath.Join("video/", kid.String())
return CheckS3File(ctx, video_filename)
}

func CheckS3File(ctx context.Context, video_filename string) (*CheckS3FileOutput, error) {

client, err := getS3Client()
if err != nil {
Expand All @@ -113,7 +117,7 @@ func CheckS3File(ctx context.Context, kid uuid.UUID) (*CheckS3FileOutput, error)
)

fdpipe := C.create_pipe()
if (fdpipe == nil) {
if fdpipe == nil {
return nil, errors.New("failed to create pipe")
}
defer C.close(fdpipe.fdr)
Expand Down
4 changes: 2 additions & 2 deletions server/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ type UploadInputDef struct {
type UploadOutput struct {
Body struct {
FileID string `json:"file_id" example:"79d97afe-b2db-4b55-af82-f16b60d8ae77" doc:"file ID"`
CheckResults CheckS3FileOutput
CheckResults CheckS3FileOutput `json:"check_results"`
}
}

func UploadKaraFile(ctx context.Context, input *UploadInput) (*UploadOutput, error) {
resp := &UploadOutput{}

res, err := CheckS3File(ctx, input.FileID)
res, err := CheckKara(ctx, input.FileID)
if (err != nil) {
return nil, err
}
Expand Down

0 comments on commit 6726a51

Please sign in to comment.