mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-08 19:22:57 +00:00

Former-commit-id: b996f4f14f3ffd92fae77d86e92d077b35ea080c [formerly e4b74308ab158ad24bd6b3dc1ce615265f972e6c] [formerly 1ea38eac2569ba58e864f1edceb56daabff5e53d [formerly 5b619337df9e9dd04e47d9c2da29a92c31adfed3]] Former-commit-id: 9117f9eeff1bbc259164b20f0561790b3c393319 [formerly c3c7b1c100c54a5ec0af528806e28b31c67da0ca] Former-commit-id: 0d95a7f55f6f3ab9f89e1c5b34db927e5763c98d
45 lines
832 B
Go
45 lines
832 B
Go
package bolt
|
|
|
|
import (
|
|
"github.com/asdine/storm"
|
|
fm "github.com/hacdias/filemanager"
|
|
)
|
|
|
|
type ShareStore struct {
|
|
DB *storm.DB
|
|
}
|
|
|
|
func (s ShareStore) Get(hash string) (*fm.ShareLink, error) {
|
|
var v *fm.ShareLink
|
|
err := s.DB.One("Hash", hash, &v)
|
|
if err == storm.ErrNotFound {
|
|
return v, fm.ErrNotExist
|
|
}
|
|
|
|
return v, err
|
|
}
|
|
|
|
func (s ShareStore) GetByPath(hash string) ([]*fm.ShareLink, error) {
|
|
var v []*fm.ShareLink
|
|
err := s.DB.Find("Path", hash, &v)
|
|
if err == storm.ErrNotFound {
|
|
return v, fm.ErrNotExist
|
|
}
|
|
|
|
return v, err
|
|
}
|
|
|
|
func (s ShareStore) Gets() ([]*fm.ShareLink, error) {
|
|
var v []*fm.ShareLink
|
|
err := s.DB.All(&v)
|
|
return v, err
|
|
}
|
|
|
|
func (s ShareStore) Save(l *fm.ShareLink) error {
|
|
return s.DB.Save(l)
|
|
}
|
|
|
|
func (s ShareStore) Delete(hash string) error {
|
|
return s.DB.DeleteStruct(&fm.ShareLink{Hash: hash})
|
|
}
|