28 lines
527 B
Go
28 lines
527 B
Go
// Copyright (C) 2021 Marius Schellenberger
|
|
|
|
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)
|
|
}
|