diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5dba16c..75722d6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,14 +4,9 @@ - @@ -150,7 +144,8 @@ - true diff --git a/pkg/internal/services/analyzer.go b/pkg/internal/services/analyzer.go index 4d98c77..7a58350 100644 --- a/pkg/internal/services/analyzer.go +++ b/pkg/internal/services/analyzer.go @@ -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 diff --git a/pkg/internal/services/merger.go b/pkg/internal/services/merger.go index acd2445..9f1b177 100644 --- a/pkg/internal/services/merger.go +++ b/pkg/internal/services/merger.go @@ -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"] diff --git a/pkg/internal/services/recycler.go b/pkg/internal/services/recycler.go index c3bc7f1..910956b 100644 --- a/pkg/internal/services/recycler.go +++ b/pkg/internal/services/recycler.go @@ -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") } diff --git a/pkg/internal/services/uploader.go b/pkg/internal/services/uploader.go index b4f132b..2343a79 100644 --- a/pkg/internal/services/uploader.go +++ b/pkg/internal/services/uploader.go @@ -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. diff --git a/settings.toml b/settings.toml index a5988af..ce0bc39 100644 --- a/settings.toml +++ b/settings.toml @@ -22,7 +22,7 @@ path = "uploads" [[destinations]] type = "local" path = "uploads/permanent" -access_baseurl = "http://localhost:8004" +access_baseurl = "http://192.168.50.133:8004" [security] internal_public_key = "keys/internal_public_key.pem"