MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / Convert

Method Convert

agent/app/service/file.go:1356–1381  ·  view source on GitHub ↗
(req request.FileConvertRequest)

Source from the content-addressed store, hash-verified

1354}
1355
1356func (f *FileService) Convert(req request.FileConvertRequest) {
1357 convertTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("FileConvert"), task.TaskExec, task.TaskScopeFileConvert, req.TaskID, 1)
1358 if err != nil {
1359 global.LOG.Errorf("Create convert task failed %v", err)
1360 return
1361 }
1362 convertTask.AddSubTask(task.GetTaskName(i18n.GetMsgByKey("FileConvert"), task.TaskExec, task.TaskScopeFileConvert), func(t *task.Task) (err error) {
1363 for _, file := range req.Files {
1364 input := filepath.Join(file.Path, file.InputFile)
1365 nameOnly := file.InputFile[0 : len(file.InputFile)-len(file.Extension)]
1366 output := filepath.Join(req.OutputPath, nameOnly+"."+file.OutputFormat)
1367 status, errMsg := convert.MediaFile(input, output, file.OutputFormat, req.DeleteSource)
1368 if status == "FAILED" {
1369 convertTask.Log(fmt.Sprintf("%s -> %s [%s]: %s\n",
1370 input, output, status, errMsg))
1371 } else {
1372 convertTask.Log(fmt.Sprintf("%s -> %s [%s]: %s\n",
1373 input, output, status, "SUCCESS"))
1374 }
1375 }
1376 return nil
1377 }, nil)
1378 go func() {
1379 _ = convertTask.Execute()
1380 }()
1381}
1382
1383func (f *FileService) ConvertLog(req dto.PageInfo) (total int64, data []response.FileConvertLog, err error) {
1384 logFilePath := filepath.Join(global.Dir.ConvertLogDir, "convert.log")

Callers

nothing calls this directly

Calls 3

AddSubTaskMethod · 0.45
LogMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected