feat: update jobs
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"quyun/providers/app"
|
||||
"quyun/providers/job"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
. "github.com/riverqueue/river"
|
||||
log "github.com/sirupsen/logrus"
|
||||
_ "go.ipao.vip/atom"
|
||||
@@ -68,20 +69,20 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
|
||||
|
||||
if err := utils.GetFrameImageFromVideo(input, output, 1); err != nil {
|
||||
log.Errorf("Error extracting image from video: %v", err)
|
||||
return JobCancel(err)
|
||||
return errors.Wrap(err, "failed to extract image from video")
|
||||
}
|
||||
defer os.RemoveAll(output)
|
||||
|
||||
fileSize, err := utils.GetFileSize(output)
|
||||
if err != nil {
|
||||
log.Errorf("Error getting file size: %v", err)
|
||||
return JobCancel(err)
|
||||
return errors.Wrap(err, "failed to get file size")
|
||||
}
|
||||
|
||||
fileMd5, err := utils.GetFileMd5(output)
|
||||
if err != nil {
|
||||
log.Errorf("Error getting file MD5: %v", err)
|
||||
return JobCancel(err)
|
||||
return errors.Wrap(err, "failed to get file MD5")
|
||||
}
|
||||
filename := fileMd5 + filepath.Ext(output)
|
||||
|
||||
@@ -103,7 +104,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
|
||||
// upload to oss
|
||||
if err := w.oss.Upload(ctx, output, imageMedia.Path, ali.WithInternal()); err != nil {
|
||||
log.Errorf("Error uploading image to OSS: %v", err)
|
||||
return JobCancel(err)
|
||||
return errors.Wrap(err, "failed to upload image to OSS")
|
||||
}
|
||||
|
||||
if w.job.Add(&RemoveFile{FilePath: output}); err != nil {
|
||||
@@ -112,7 +113,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
|
||||
|
||||
if err := models.Medias.Create(ctx, imageMedia); err != nil {
|
||||
log.Errorf("Error creating media record: %v", err)
|
||||
return JobCancel(err)
|
||||
return errors.Wrap(err, "failed to create media record")
|
||||
}
|
||||
|
||||
dst := filepath.Join(w.app.StoragePath, media.Path)
|
||||
@@ -122,7 +123,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
|
||||
|
||||
if w.job.Add(&PublishDraftPosts{MediaHash: media.Hash}); err != nil {
|
||||
log.Errorf("Error adding job: %v", err)
|
||||
return JobCancel(err)
|
||||
return errors.Wrap(err, "failed to add job")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user