🐛 Bug fixes and logging

This commit is contained in:
2024-07-29 13:22:57 +08:00
parent 8f08d85fb1
commit c46d7fa312
7 changed files with 57 additions and 20 deletions

View File

@@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/models"
"github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go"
@@ -39,6 +40,8 @@ func ReUploadFileToPermanent(meta models.Attachment) error {
return fmt.Errorf("attachment isn't in temporary storage, unable to process")
}
meta.Destination = models.AttachmentDstPermanent
destMap := viper.GetStringMap("destinations.permanent")
var dest models.BaseDestination
@@ -76,6 +79,9 @@ func ReUploadFileToPermanent(meta models.Attachment) error {
if err != nil {
return fmt.Errorf("unable to copy data to dest file: %v", err)
}
database.C.Save(&meta)
metadataCache[meta.ID] = meta
return nil
case models.DestinationTypeS3:
var destConfigured models.S3Destination
@@ -97,6 +103,9 @@ func ReUploadFileToPermanent(meta models.Attachment) error {
if err != nil {
return fmt.Errorf("unable to upload file to s3: %v", err)
}
database.C.Save(&meta)
metadataCache[meta.ID] = meta
return nil
default:
return fmt.Errorf("invalid destination: unsupported protocol %s", dest.Type)