docstore/pkg/fs/scan.go
2019-05-05 19:06:51 +02:00

26 lines
482 B
Go

package fs
import "errors"
func (fs *Filesystem) AddScan(path string) error {
if fs.CheckScan(path) {
return errors.New("file '" + path + "' is already scanning")
}
fs.m.Lock()
defer fs.m.Unlock()
fs.scan[path] = struct{}{}
return nil
}
func (fs *Filesystem) CheckScan(path string) (ok bool) {
fs.m.RLock()
defer fs.m.RUnlock()
_, ok = fs.scan[path]
return
}
func (fs *Filesystem) RemoveScan(path string) {
fs.m.Lock()
defer fs.m.Unlock()
delete(fs.scan, path)
}