Go: refactor UUID functions (#16695)

As title

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-07 17:22:08 +08:00
committed by GitHub
parent 5236c8f659
commit 7df7384b21
38 changed files with 104 additions and 170 deletions

View File

@@ -25,11 +25,10 @@ import (
"ragflow/internal/dao"
"ragflow/internal/entity"
"ragflow/internal/storage"
"ragflow/internal/utility"
"sort"
"strings"
"time"
"github.com/google/uuid"
"go.uber.org/zap"
"gorm.io/gorm"
)
@@ -65,7 +64,7 @@ func (s *FileCommitService) CreateCommit(folderID, authorID, message string, cha
}
// 3. Create commit record
commitID := generateCommitUUID()
commitID := utility.GenerateUUID()
nowMs := time.Now().UnixMilli()
commit := &entity.FileCommit{
@@ -105,7 +104,7 @@ func (s *FileCommitService) CreateCommit(folderID, authorID, message string, cha
for _, change := range changes {
item := &entity.FileCommitItem{
ID: generateCommitUUID(),
ID: utility.GenerateUUID(),
CommitID: commitID,
FileID: change.FileID,
Operation: change.Operation,
@@ -629,9 +628,3 @@ func computeLiveFileHash(folderID, fileID string, file *entity.File) string {
hash := sha256.Sum256(data)
return hex.EncodeToString(hash[:])
}
// generateCommitUUID generates a UUID without dashes
func generateCommitUUID() string {
id := uuid.New().String()
return strings.ReplaceAll(id, "-", "")
}