feat: switch upload hash to md5

This commit is contained in:
2026-01-08 15:40:48 +08:00
parent 6ffe58ffb4
commit 7f162b7c45
8 changed files with 348 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ package services
import (
"context"
"crypto/sha256"
"crypto/md5"
"encoding/hex"
"encoding/json"
"io"
@@ -196,7 +196,7 @@ func (s *common) CompleteUpload(ctx context.Context, userID int64, form *common_
}
defer dst.Close()
hasher := sha256.New()
hasher := md5.New()
var totalSize int64
for _, partNum := range parts {
@@ -346,7 +346,7 @@ func (s *common) Upload(
}
// Hash calculation while copying
hasher := sha256.New()
hasher := md5.New()
size, err := io.Copy(io.MultiWriter(dst, hasher), src)
dst.Close() // Close immediately to allow removal if needed
if err != nil {