Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace os.Chdir logic in ISO9660 with absolute paths to allow for concurrent use #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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