Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

fix: lazy load version, build correct multipart #305

Merged
merged 1 commit into from
Aug 22, 2023
Merged

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Aug 17, 2023

See ipfs/kubo#10068.

Will be released in subsequent PR.

@hacdias hacdias mentioned this pull request Aug 17, 2023
10 tasks
@hacdias hacdias requested review from lidel, aschmahmann, Jorropo and a team August 17, 2023 11:01
@hacdias hacdias self-assigned this Aug 17, 2023
@hacdias hacdias marked this pull request as ready for review August 17, 2023 11:47
Copy link

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should hoist:

err = s.loadRemoteVersion()
	if err != nil {
		return err
	}

        fileReader := files.NewMultiFileReader(slf, true, s.version.LT(encodedAbsolutePathVersion))

In a private method of the shell that returns a file Reader and an error.

Except than this LGTM

@hacdias hacdias force-pushed the go-1.20-fix branch 2 times, most recently from 6328245 to 8860c35 Compare August 22, 2023 11:14
@ipfs ipfs deleted a comment from github-actions bot Aug 22, 2023
@hacdias hacdias merged commit 8e37330 into master Aug 22, 2023
9 checks passed
@hacdias hacdias deleted the go-1.20-fix branch August 22, 2023 11:24
Comment on lines +133 to +151
func (s *Shell) loadRemoteVersion() error {
if s.version == nil {
version, _, err := s.Version()
if err != nil {
return err
}

remoteVersion, err := semver.New(version)
if err != nil {
return err
}

s.versionOnce.Do(func() {
s.version = remoteVersion
})
}

return nil
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure the .Do should englobe all of loadRemoteVersion's body.
Because this code will concurrently request the version number but save it only once, this leads to a data race between your s.version == nil and s.version = remoteVersion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix in separate PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants