🚚 Move io related functions to fs internal package

This commit is contained in:
2024-12-28 14:07:53 +08:00
parent 99dd7f55e0
commit dda85eae98
7 changed files with 26 additions and 18 deletions

View File

@ -6,6 +6,7 @@ import (
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/fs"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/models"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/server/exts"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/services"
@ -115,10 +116,19 @@ func uploadFragmentChunk(c *fiber.Ctx) error {
return c.JSON(meta)
}
attachment, err := services.MergeFileChunks(meta, chunkArrange)
// Merge & post-upload
attachment, err := fs.MergeFileChunks(meta, chunkArrange)
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} else if !c.QueryBool("analyzeNow", false) {
}
// Post-upload tasks
if err := database.C.Save(&attachment).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
services.CacheAttachment(attachment)
if !c.QueryBool("analyzeNow", false) {
services.AnalyzeAttachment(attachment)
} else {
services.PublishAnalyzeTask(attachment)