mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-08-17 09:26:04 +00:00
Fix incorrect start time in AuditID.CompareTime.
This commit is contained in:
@@ -50,6 +50,8 @@ func GetPrincipal(ctx context.Context) *Principal {
|
||||
return nil
|
||||
}
|
||||
|
||||
var AuditSnowflakeStartTime = time.Date(2025, 12, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
type AuditID int64
|
||||
|
||||
func GenerateAuditID() AuditID {
|
||||
@@ -74,6 +76,7 @@ func (id AuditID) String() string {
|
||||
|
||||
func (id AuditID) CompareTime(when time.Time) int {
|
||||
idMillis := int64(id) >> (snowflake.MachineIDLength + snowflake.SequenceLength)
|
||||
idMillis += AuditSnowflakeStartTime.UnixMilli()
|
||||
whenMillis := when.UTC().UnixNano() / 1e6
|
||||
return cmp.Compare(idMillis, whenMillis)
|
||||
}
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ func configureFallback(_ context.Context) (err error) {
|
||||
|
||||
// Thread-unsafe, must be called only during initial configuration.
|
||||
func configureAudit(_ context.Context) (err error) {
|
||||
snowflake.SetStartTime(time.Date(2025, 12, 1, 0, 0, 0, 0, time.UTC))
|
||||
snowflake.SetStartTime(AuditSnowflakeStartTime)
|
||||
snowflake.SetMachineID(config.Audit.NodeID)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user