1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-10 02:35:58 +01:00

Draw recorder ids randomly.

This commit is contained in:
Juliusz Chroboczek 2020-09-18 10:23:53 +02:00
parent 7ce61a1100
commit 98245cbd24

View file

@ -1,11 +1,12 @@
package disk
import (
crand "crypto/rand"
"errors"
"fmt"
"os"
"path/filepath"
"strconv"
"encoding/hex"
"sync"
"time"
@ -30,18 +31,10 @@ type Client struct {
closed bool
}
var idCounter struct {
mu sync.Mutex
counter int
}
func newId() string {
idCounter.mu.Lock()
defer idCounter.mu.Unlock()
s := strconv.FormatInt(int64(idCounter.counter), 16)
idCounter.counter++
return s
b := make([]byte, 16)
crand.Read(b)
return hex.EncodeToString(b)
}
func New(g *group.Group) *Client {