feat(fileinfostore): support GetSharing

This commit is contained in:
hexxa 2021-08-11 15:29:53 +08:00 committed by Hexxa
parent c78692df52
commit e74c3c34e3
2 changed files with 13 additions and 0 deletions

View file

@ -13,6 +13,7 @@ const (
type IFileInfoStore interface {
AddSharing(dirPath string) error
DelSharing(dirPath string) error
GetSharing(dirPath string) (bool, bool)
ListSharings(prefix string) (map[string]bool, error)
}
@ -47,6 +48,10 @@ func (us *FileInfoStore) DelSharing(dirPath string) error {
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) {
return us.store.ListBoolsByPrefixIn(prefix, SharingNs)
}

View file

@ -30,6 +30,10 @@ func TestUserStores(t *testing.T) {
if !sharingMap[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 {
@ -47,6 +51,10 @@ func TestUserStores(t *testing.T) {
if sharingMap[dirPath] {
t.Fatalf("sharing(%s) should not exist", dirPath)
}
_, exist := store.GetSharing(dirPath)
if exist {
t.Fatalf("get sharing(%t) should not exit", exist)
}
}
}