初版功能完成
ci / Go checks (ubuntu-latest) (push) Has been cancelled
ci / Go checks (windows-latest) (push) Has been cancelled

This commit is contained in:
qsc
2026-08-29 13:12:17 +08:00
commit 142e5dc7d6
217 changed files with 21313 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package bootstrap
import (
"context"
"github.com/google/uuid"
"remlink/internal/database"
)
const serverIDSetting = "server_id"
// EnsureServerID returns the stable Server UUID stored in SQLite.
func EnsureServerID(ctx context.Context, store *database.Store) (string, error) {
value, found, err := database.GetSetting(ctx, store.DB(), serverIDSetting)
if err != nil {
return "", err
}
if found {
if _, err := uuid.Parse(value); err != nil {
return "", err
}
return value, nil
}
value = uuid.NewString()
if err := database.SetSetting(ctx, store.DB(), serverIDSetting, value); err != nil {
return "", err
}
return value, nil
}