✨ File operations queue
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/models"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
_ "image/gif"
|
||||
@@ -26,6 +27,15 @@ func PublishAnalyzeTask(file models.Attachment) {
|
||||
fileAnalyzeQueue <- file
|
||||
}
|
||||
|
||||
func StartConsumeAnalyzeTask() {
|
||||
for {
|
||||
task := <-fileAnalyzeQueue
|
||||
if err := AnalyzeAttachment(task); err != nil {
|
||||
log.Error().Err(err).Any("task", task).Msg("A file analyze task failed...")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func AnalyzeAttachment(file models.Attachment) error {
|
||||
if file.Destination != models.AttachmentDstTemporary {
|
||||
return fmt.Errorf("attachment isn't in temporary storage, unable to analyze")
|
||||
|
Reference in New Issue
Block a user