🐛 Still reading the abandoned temporary dest config

This commit is contained in:
2024-11-10 00:50:47 +08:00
parent c41f8b77ce
commit 6cda5751df
6 changed files with 39 additions and 44 deletions

View File

@ -116,7 +116,7 @@ func AnalyzeAttachment(file models.Attachment) error {
// Do analyze jobs
if !file.IsAnalyzed || len(file.HashCode) == 0 {
destMap := viper.GetStringMap("destinations.temporary")
destMap := viper.GetStringMap("destinations.0")
var dest models.LocalDestination
rawDest, _ := jsoniter.Marshal(destMap)
@ -259,7 +259,7 @@ func AnalyzeAttachment(file models.Attachment) error {
func HashAttachment(file models.Attachment) (hash string, err error) {
const chunkSize = 32 * 1024
destMap := viper.GetStringMapString("destinations.temporary")
destMap := viper.GetStringMapString("destinations.0")
destPath := filepath.Join(destMap["path"], file.Uuid)
// Check if the file exists

View File

@ -13,7 +13,7 @@ import (
func MergeFileChunks(meta models.Attachment, arrange []string) (models.Attachment, error) {
// Fetch destination from config
destMap := viper.GetStringMapString("destinations.temporary")
destMap := viper.GetStringMapString("destinations.0")
var dest models.LocalDestination
dest.Path = destMap["path"]

View File

@ -98,7 +98,7 @@ func RunScheduleDeletionTask() {
func DeleteFile(meta models.Attachment) error {
if !meta.IsUploaded {
destMap := viper.GetStringMap("destinations.temporary")
destMap := viper.GetStringMap("destinations.0")
var dest models.LocalDestination
rawDest, _ := jsoniter.Marshal(destMap)
_ = jsoniter.Unmarshal(rawDest, &dest)
@ -113,7 +113,7 @@ func DeleteFile(meta models.Attachment) error {
var destMap map[string]any
if meta.Destination == models.AttachmentDstTemporary {
destMap = viper.GetStringMap("destinations.temporary")
destMap = viper.GetStringMap("destinations.0")
} else {
destMap = viper.GetStringMap("destinations.permanent")
}

View File

@ -19,7 +19,7 @@ import (
)
func UploadFileToTemporary(ctx *fiber.Ctx, file *multipart.FileHeader, meta models.Attachment) error {
destMap := viper.GetStringMap("destinations.temporary")
destMap := viper.GetStringMap(fmt.Sprintf("destinations.%d", meta.Destination))
var dest models.BaseDestination
rawDest, _ := jsoniter.Marshal(destMap)
@ -36,7 +36,7 @@ func UploadFileToTemporary(ctx *fiber.Ctx, file *multipart.FileHeader, meta mode
}
func UploadChunkToTemporary(ctx *fiber.Ctx, cid string, file *multipart.FileHeader, meta models.Attachment) error {
destMap := viper.GetStringMap("destinations.temporary")
destMap := viper.GetStringMap("destinations.0")
var dest models.BaseDestination
rawDest, _ := jsoniter.Marshal(destMap)
@ -58,7 +58,7 @@ func UploadChunkToTemporary(ctx *fiber.Ctx, cid string, file *multipart.FileHead
}
func UploadChunkToTemporaryWithRaw(ctx *fiber.Ctx, cid string, raw []byte, meta models.Attachment) error {
destMap := viper.GetStringMap("destinations.temporary")
destMap := viper.GetStringMap("destinations.0")
var dest models.BaseDestination
rawDest, _ := jsoniter.Marshal(destMap)
@ -80,7 +80,7 @@ func UploadChunkToTemporaryWithRaw(ctx *fiber.Ctx, cid string, raw []byte, meta
}
func CheckChunkExistsInTemporary(meta models.Attachment, cid string) bool {
destMap := viper.GetStringMap("destinations.temporary")
destMap := viper.GetStringMap("destinations.0")
var dest models.LocalDestination
rawDest, _ := jsoniter.Marshal(destMap)
@ -110,7 +110,7 @@ func ReUploadFileToPermanent(meta models.Attachment, dst int) error {
rawDest, _ := jsoniter.Marshal(destMap)
_ = jsoniter.Unmarshal(rawDest, &dest)
prevDestMap := viper.GetStringMap("destinations.temporary")
prevDestMap := viper.GetStringMap("destinations.0")
// Currently, the temporary destination only supports the local.
// So we can do this.