take into account the walk function when checking if a crawl is already running for a path
This commit is contained in:
parent
11edbeadc3
commit
4a74b00d46
|
@ -91,7 +91,7 @@ func PathOutsideRoot(fullPath string) bool {
|
|||
}
|
||||
|
||||
func RetardCheck(fullPath string) {
|
||||
// Make sure we never do anything outside of the root dir.
|
||||
// Make sure we never do anything outside the root dir.
|
||||
if PathOutsideRoot(fullPath) {
|
||||
panic(fmt.Sprintf("NewItem was not passed an absolute path. The path must start with the RootDir (%s). Failing path: %s", config.GetConfig().RootDir, fullPath))
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ func isSubpath(path, subpath string) bool {
|
|||
}
|
||||
|
||||
func (dc *DirectoryCrawler) startCrawl(path string, function string) bool {
|
||||
if dc.IsCrawlActive(path) {
|
||||
if dc.IsCrawlActive(path, &function) {
|
||||
return false
|
||||
}
|
||||
activeCrawls[path] = &ActiveCrawl{
|
||||
|
@ -119,11 +119,13 @@ func (dc *DirectoryCrawler) endCrawl(path string) {
|
|||
delete(activeCrawls, path)
|
||||
}
|
||||
|
||||
func (dc *DirectoryCrawler) IsCrawlActive(path string) bool {
|
||||
func (dc *DirectoryCrawler) IsCrawlActive(path string, function *string) bool {
|
||||
activeCrawlsMutex.Lock()
|
||||
defer activeCrawlsMutex.Unlock()
|
||||
_, active := activeCrawls[path]
|
||||
return active
|
||||
if crawl, active := activeCrawls[path]; active {
|
||||
return crawl.Function == *function
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetActiveCrawls() map[string]*ActiveCrawl {
|
||||
|
|
|
@ -37,7 +37,7 @@ func CheckAndRecache(path string) {
|
|||
|
||||
func Recache(path string) error {
|
||||
dc := DirectoryCrawler.NewDirectoryCrawler()
|
||||
if dc.IsCrawlActive(path) {
|
||||
if dc.IsCrawlActive(path, nil) {
|
||||
return errors.New("rejecting crawl, already in progress for this path")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue