some bug fixes
This commit is contained in:
parent
0e49d60994
commit
0e914c629e
16 changed files with 179 additions and 52 deletions
26
pkg/fs/scan.go
Normal file
26
pkg/fs/scan.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue