some bug fixes

This commit is contained in:
ston1th 2019-05-05 19:06:51 +02:00
commit 0e914c629e
16 changed files with 179 additions and 52 deletions

26
pkg/fs/scan.go Normal file
View file

@ -0,0 +1,26 @@
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)
}