diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1a3ab33..41a8899 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,19 +4,12 @@
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
@@ -128,7 +121,6 @@
-
@@ -153,7 +145,8 @@
-
+
+
true
diff --git a/pkg/internal/models/attachments.go b/pkg/internal/models/attachments.go
index d62eee5..ca5c960 100644
--- a/pkg/internal/models/attachments.go
+++ b/pkg/internal/models/attachments.go
@@ -25,7 +25,6 @@ type Attachment struct {
Alternative string `json:"alt"`
MimeType string `json:"mimetype"`
HashCode string `json:"hash"`
- UserHash *string `json:"user_hash"`
Destination AttachmentDst `json:"destination"`
RefCount int `json:"ref_count"`
diff --git a/pkg/internal/server/api/up_multipart_api.go b/pkg/internal/server/api/up_multipart_api.go
index 991b7bb..8b17573 100644
--- a/pkg/internal/server/api/up_multipart_api.go
+++ b/pkg/internal/server/api/up_multipart_api.go
@@ -19,7 +19,6 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
var data struct {
Pool string `json:"pool" validate:"required"`
Size int64 `json:"size" validate:"required"`
- Hash string `json:"hash" validate:"required"`
Alternative string `json:"alt"`
MimeType string `json:"mimetype"`
Metadata map[string]any `json:"metadata"`
@@ -43,7 +42,6 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
}
metadata, err := services.NewAttachmentPlaceholder(database.C, user, models.Attachment{
- UserHash: &data.Hash,
Alternative: data.Alternative,
MimeType: data.MimeType,
Metadata: data.Metadata,
@@ -57,7 +55,10 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
}
- return c.JSON(metadata)
+ return c.JSON(fiber.Map{
+ "chunk_size": viper.GetInt64("performance.file_chunk_size"),
+ "meta": metadata,
+ })
}
func uploadAttachmentMultipart(c *fiber.Ctx) error {
diff --git a/pkg/internal/services/analyzer.go b/pkg/internal/services/analyzer.go
index caa28ca..adebacd 100644
--- a/pkg/internal/services/analyzer.go
+++ b/pkg/internal/services/analyzer.go
@@ -99,6 +99,14 @@ func AnalyzeAttachment(file models.Attachment) error {
var start time.Time
+ if len(file.HashCode) == 0 {
+ if hash, err := HashAttachment(file); err != nil {
+ return err
+ } else {
+ file.HashCode = hash
+ }
+ }
+
// Do analyze jobs
if !file.IsAnalyzed || len(file.HashCode) == 0 {
destMap := viper.GetStringMap("destinations.temporary")
@@ -158,12 +166,6 @@ func AnalyzeAttachment(file models.Attachment) error {
"color_space": stream.ColorSpace,
}
}
-
- if hash, err := HashAttachment(file); err != nil {
- return err
- } else {
- file.HashCode = hash
- }
}
tx := database.C.Begin()
diff --git a/pkg/internal/services/merger.go b/pkg/internal/services/merger.go
index 24eefc2..a6821b3 100644
--- a/pkg/internal/services/merger.go
+++ b/pkg/internal/services/merger.go
@@ -44,5 +44,7 @@ func MergeFileChunks(meta models.Attachment, arrange []string) (models.Attachmen
meta.IsUploaded = true
database.C.Save(&meta)
+ PublishAnalyzeTask(meta)
+
return meta, nil
}
diff --git a/settings.toml b/settings.toml
index 3c82f1f..35ebb20 100644
--- a/settings.toml
+++ b/settings.toml
@@ -30,7 +30,7 @@ access_token_duration = 300
refresh_token_duration = 2592000
[performance]
-file_chunk_size = 5242880
+file_chunk_size = 26214400
[database]
dsn = "host=localhost user=postgres password=password dbname=hy_paperclip port=5432 sslmode=disable"