Skip to content

Conversation

@borisroman
Copy link

Hello,

I have a use case where I create multiple ISO files concurrently with different contents and names.

The os.Chdir() call changes the working dir for the entire app. Having multiple go routines that call the function does end up in a race condition which has the correct working dir.

This patch uses absolute paths and does not rely on the working directory to be changed.

Thanks for maintaining the package!

@deitch
Copy link
Collaborator

deitch commented Mar 26, 2023

Yeah, that os.Chdir() never was great.

fs.FS has made it into go since this was written. Maybe redo the whole this with that?

	fsys := os.DirFS(workspace)
 	dirList := make(map[string]*finalizeFileInfo)
 	fileList := make([]*finalizeFileInfo, 0)

 	var entry *finalizeFileInfo
 	err = fs.WalkDir(fsys, ".", func(fp string, d fs.DirEntry, err error) error {

Probably requires a bit more cleanup than that, but it would solve your problem with even less effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants