aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/storage.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-09-04 12:06:44 +0200
committerGitHub <noreply@github.com>2018-09-04 12:06:44 +0200
commit2f1583896bcc3c182d8165d6aeeb23c771cc5417 (patch)
tree883c48f088d16ef07c97fdb93888c5947df994f4 /storage/filesystem/storage.go
parent8e76874ae2a3f5029269af76a86f0ee294699df9 (diff)
parent659ec443b4a975e3adf78f24e59ad69d210d2c0b (diff)
downloadgo-git-2f1583896bcc3c182d8165d6aeeb23c771cc5417.tar.gz
Merge pull request #941 from jfontan/improvement/static-mode
plumbing/storer: add ExclusiveAccess option to Storer
Diffstat (limited to 'storage/filesystem/storage.go')
-rw-r--r--storage/filesystem/storage.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go
index 622bb4a..25b3653 100644
--- a/storage/filesystem/storage.go
+++ b/storage/filesystem/storage.go
@@ -22,10 +22,29 @@ type Storage struct {
ModuleStorage
}
+// Options holds configuration for the storage.
+type Options struct {
+ // ExclusiveAccess means that the filesystem is not modified externally
+ // while the repo is open.
+ ExclusiveAccess bool
+}
+
// NewStorage returns a new Storage backed by a given `fs.Filesystem`
func NewStorage(fs billy.Filesystem) (*Storage, error) {
- dir := dotgit.New(fs)
- o, err := NewObjectStorage(dir)
+ return NewStorageWithOptions(fs, Options{})
+}
+
+// NewStorageWithOptions returns a new Storage backed by a given `fs.Filesystem`
+func NewStorageWithOptions(
+ fs billy.Filesystem,
+ ops Options,
+) (*Storage, error) {
+ dirOps := dotgit.Options{
+ ExclusiveAccess: ops.ExclusiveAccess,
+ }
+
+ dir := dotgit.NewWithOptions(fs, dirOps)
+ o, err := NewObjectStorageWithOptions(dir, ops)
if err != nil {
return nil, err
}