feat(fileinfostore): support GetSharing
This commit is contained in:
parent
c78692df52
commit
e74c3c34e3
2 changed files with 13 additions and 0 deletions
|
@ -13,6 +13,7 @@ const (
|
||||||
type IFileInfoStore interface {
|
type IFileInfoStore interface {
|
||||||
AddSharing(dirPath string) error
|
AddSharing(dirPath string) error
|
||||||
DelSharing(dirPath string) error
|
DelSharing(dirPath string) error
|
||||||
|
GetSharing(dirPath string) (bool, bool)
|
||||||
ListSharings(prefix string) (map[string]bool, error)
|
ListSharings(prefix string) (map[string]bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +48,10 @@ func (us *FileInfoStore) DelSharing(dirPath string) error {
|
||||||
return us.store.DelBoolIn(SharingNs, dirPath)
|
return us.store.DelBoolIn(SharingNs, dirPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (us *FileInfoStore) GetSharing(dirPath string) (bool, bool) {
|
||||||
|
return us.store.GetBoolIn(SharingNs, dirPath)
|
||||||
|
}
|
||||||
|
|
||||||
func (us *FileInfoStore) ListSharings(prefix string) (map[string]bool, error) {
|
func (us *FileInfoStore) ListSharings(prefix string) (map[string]bool, error) {
|
||||||
return us.store.ListBoolsByPrefixIn(prefix, SharingNs)
|
return us.store.ListBoolsByPrefixIn(prefix, SharingNs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ func TestUserStores(t *testing.T) {
|
||||||
if !sharingMap[sharingDir] {
|
if !sharingMap[sharingDir] {
|
||||||
t.Fatalf("sharing(%s) not found", sharingDir)
|
t.Fatalf("sharing(%s) not found", sharingDir)
|
||||||
}
|
}
|
||||||
|
mustTrue, exist := store.GetSharing(sharingDir)
|
||||||
|
if !mustTrue || !exist {
|
||||||
|
t.Fatalf("get sharing(%t %t) should exist", mustTrue, exist)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dirPath := range dirPaths {
|
for _, dirPath := range dirPaths {
|
||||||
|
@ -47,6 +51,10 @@ func TestUserStores(t *testing.T) {
|
||||||
if sharingMap[dirPath] {
|
if sharingMap[dirPath] {
|
||||||
t.Fatalf("sharing(%s) should not exist", dirPath)
|
t.Fatalf("sharing(%s) should not exist", dirPath)
|
||||||
}
|
}
|
||||||
|
_, exist := store.GetSharing(dirPath)
|
||||||
|
if exist {
|
||||||
|
t.Fatalf("get sharing(%t) should not exit", exist)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue