Skip to content

Commit

Permalink
String matching
Browse files Browse the repository at this point in the history
Signed-off-by: AbstractionFactory <[email protected]>
  • Loading branch information
abstractionfactory committed Oct 14, 2024
1 parent b2d00c5 commit 5933a80
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions backend/internal/moduleindex/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,20 +572,12 @@ func (g generator) extractSubmodules(ctx context.Context, addr ModuleAddr, ver M

const directoryPrefix = "modules"

// This section guards against files named "modules"
entries, err := workingCopy.ReadDir("")
entries, err := workingCopy.ReadDir(directoryPrefix)
if err != nil {
return err
}
for _, entry := range entries {
if entry.Name() == directoryPrefix && !entry.IsDir() {
if os.IsNotExist(err) {
return nil
}
}

entries, err = workingCopy.ReadDir(directoryPrefix)
if err != nil {
if os.IsNotExist(err) {
if strings.Contains(err.Error(), "not a directory") {
return nil
}
return err
Expand Down Expand Up @@ -633,20 +625,12 @@ func (g generator) extractExamples(ctx context.Context, moduleAddr ModuleAddr, v
// that the submodule exists. However, we do not index the contents of the submodule.
const directoryPrefix = "examples"

// This section guards against files named "examples"
entries, err := workingCopy.ReadDir("")
entries, err := workingCopy.ReadDir(directoryPrefix)
if err != nil {
return err
}
for _, entry := range entries {
if entry.Name() == directoryPrefix && !entry.IsDir() {
if os.IsNotExist(err) {
return nil
}
}

entries, err = workingCopy.ReadDir(directoryPrefix)
if err != nil {
if os.IsNotExist(err) {
if strings.Contains(err.Error(), "not a directory") {
return nil
}
return err
Expand Down

0 comments on commit 5933a80

Please sign in to comment.