mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-22 10:37:23 +00:00
OAS: Some minor fixes (#762)
* Commit some fixes * Accept expected Co-authored-by: Igor Gov <iggvrv@gmail.com>
This commit is contained in:
@@ -21,20 +21,33 @@ func getFiles(baseDir string) (result []string, err error) {
|
||||
result = make([]string, 0)
|
||||
logger.Log.Infof("Reading files from tree: %s", baseDir)
|
||||
|
||||
inputs := []string{baseDir}
|
||||
|
||||
// https://yourbasic.org/golang/list-files-in-directory/
|
||||
err = filepath.Walk(baseDir,
|
||||
func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
if !info.IsDir() && (ext == ".har" || ext == ".ldjson") {
|
||||
result = append(result, path)
|
||||
}
|
||||
visitor := func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.Mode()&os.ModeSymlink != 0 {
|
||||
path, _ = os.Readlink(path)
|
||||
inputs = append(inputs, path)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
if !info.IsDir() && (ext == ".har" || ext == ".ldjson") {
|
||||
result = append(result, path)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
for len(inputs) > 0 {
|
||||
path := inputs[0]
|
||||
inputs = inputs[1:]
|
||||
err = filepath.Walk(path, visitor)
|
||||
}
|
||||
|
||||
sort.SliceStable(result, func(i, j int) bool {
|
||||
return fileSize(result[i]) < fileSize(result[j])
|
||||
@@ -126,7 +139,7 @@ func feedEntry(entry *har.Entry, source string, isSync bool, file string) {
|
||||
logger.Log.Debugf("Interesting: %s", entry.Request.URL)
|
||||
}
|
||||
|
||||
ews := EntryWithSource{Entry: *entry, Source: source}
|
||||
ews := EntryWithSource{Entry: *entry, Source: source, Id: uint(0)}
|
||||
if isSync {
|
||||
GetOasGeneratorInstance().entriesChan <- ews // blocking variant, right?
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user