Skip to content

Commit

Permalink
Handling the case when the 'modules' or 'examples' directory is actua…
Browse files Browse the repository at this point in the history
…lly a file

Signed-off-by: AbstractionFactory <[email protected]>
  • Loading branch information
abstractionfactory committed Nov 15, 2024
1 parent 122dfe3 commit 21c117b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/internal/moduleindex/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ func (g generator) extractSubmodules(ctx context.Context, addr ModuleAddr, ver M
// that the submodule exists. However, we do not index the contents of the submodule.

const directoryPrefix = "modules"
// Check if the modules directory is actually a file.
if _, err := workingCopy.Open(directoryPrefix); err == nil {
// This is a file, ignore it.
return nil
}
entries, err := workingCopy.ReadDir(directoryPrefix)
if err != nil {
if os.IsNotExist(err) {
Expand Down Expand Up @@ -643,6 +648,11 @@ func (g generator) extractExamples(ctx context.Context, moduleAddr ModuleAddr, v
// Note: we extract the fact that an example exists even if the license is not OK because we just index the fact
// that the submodule exists. However, we do not index the contents of the submodule.
const directoryPrefix = "examples"
// Check if the examples directory is actually a file.
if _, err := workingCopy.Open(directoryPrefix); err == nil {
// This is a file, ignore it.
return nil
}
entries, err := workingCopy.ReadDir(directoryPrefix)
if err != nil {
if os.IsNotExist(err) {
Expand Down

0 comments on commit 21c117b

Please sign in to comment.