Skip to content

Commit

Permalink
fix: fix bug when creating big projects
Browse files Browse the repository at this point in the history
In the case of very big projects classes proji would break with an error
that reported that too many files were opened at the same time.

Until now files were created with os.OpenFile() which creates files if
they don't already exist and then opens them for editing or reading. The
editing/reading part is obviously unnecessary for proji anyways. Now
files are created with os.Create() which is generally more fitting and
seems to solve the issue with unclosed file handles. The file handles
are now closed explicitly too.

Fixes #110
  • Loading branch information
nikoksr committed Mar 9, 2020
1 parent 60737be commit 71062dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/proji/storage/item/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ func (proj *Project) createFiles() error {

// Replace keyword with project name
file.Destination = re.ReplaceAllString(file.Destination, proj.Name)
_, err := os.OpenFile(file.Destination, os.O_RDONLY|os.O_CREATE, os.ModePerm)

// Create file
f, err := os.Create(file.Destination)
if err != nil {
return err
}
_ = f.Close()
}
return nil
}
Expand Down

0 comments on commit 71062dc

Please sign in to comment.