mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Fixed runaway rolodex.
The rolodex was running away and locking up vacuum. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -108,7 +108,7 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
|
||||
}
|
||||
// check for circular references
|
||||
if config.Logger != nil {
|
||||
config.Logger.Debug("indexing rolodex")
|
||||
config.Logger.Debug("checking for circular references")
|
||||
}
|
||||
now = time.Now()
|
||||
if !config.SkipCircularReferenceCheck {
|
||||
|
||||
@@ -58,7 +58,7 @@ func FindComponent(root *yaml.Node, componentId, absoluteFilePath string, index
|
||||
friendlySearch = "$"
|
||||
}
|
||||
path, err := yamlpath.NewPath(friendlySearch)
|
||||
if path == nil || err != nil {
|
||||
if path == nil || err != nil || root == nil {
|
||||
return nil // no component found
|
||||
}
|
||||
res, _ := path.Find(root)
|
||||
|
||||
@@ -108,6 +108,7 @@ func (l *LocalFS) Open(name string) (fs.File, error) {
|
||||
extractedFile, extErr = l.extractFile(name)
|
||||
if extErr != nil {
|
||||
l.processingFiles.Delete(name)
|
||||
processingWaiter.done = true
|
||||
return nil, extErr
|
||||
}
|
||||
if extractedFile != nil {
|
||||
@@ -152,6 +153,10 @@ func (l *LocalFS) Open(name string) (fs.File, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
waiter, _ := l.processingFiles.Load(name)
|
||||
if waiter != nil {
|
||||
waiter.(*waiterLocal).done = true
|
||||
}
|
||||
l.processingFiles.Delete(name)
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
|
||||
}
|
||||
|
||||
@@ -284,6 +284,11 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
|
||||
"AllowRemoteLookup to true as part of the index configuration", remoteURL)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(remoteURL, "http") {
|
||||
i.logger.Debug("[rolodex remote loader] not a remote file, ignoring", "file", remoteURL)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
remoteParsedURL, err := url.Parse(remoteURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -306,6 +311,7 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
|
||||
"remoteURL", remoteParsedURL.String())
|
||||
|
||||
for !wait.done {
|
||||
i.logger.Debug("[rolodex remote loader] sleeping, waiting for file to return", "file", remoteURL)
|
||||
time.Sleep(500 * time.Nanosecond) // breathe for a few nanoseconds.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user