Skip to content

Commit

Permalink
Merge pull request #245 from opentofu/bugfix/directory-file-handling
Browse files Browse the repository at this point in the history
Handling file->dir mismatch
  • Loading branch information
abstractionfactory authored Nov 15, 2024
2 parents 122dfe3 + 21c117b commit c338959
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 c338959

Please sign in to comment.