ref: 85f1212724e037e6934203f04a3f6231ac609503
dir: /refstore/files/new.go/
package files
import (
"math/rand"
"os"
"time"
"codeberg.org/lindenii/furgit/objectid"
)
// New creates one files ref store rooted at one repository gitdir.
func New(root *os.Root, algo objectid.Algorithm, packedRefsTimeout time.Duration) (*Store, error) {
if algo.Size() == 0 {
return nil, objectid.ErrInvalidAlgorithm
}
commonRoot, err := openCommonRoot(root)
if err != nil {
return nil, err
}
return &Store{
gitRoot: root,
commonRoot: commonRoot,
algo: algo,
lockRand: rand.New(rand.NewSource(time.Now().UnixNano())), //nolint:gosec
packedRefsTimeout: packedRefsTimeout,
}, nil
}