Repository navigation
Conversation
Reload parsed every data source on top of the sections already in memory, so a key or section deleted from the source stayed around after a reload, and with AllowNonUniqueSections every reload appended another copy of each section. Reload now clears the sections before parsing. Append keeps merging on top of the current sections, so sections created in memory before Append are not lost. Fixes go-ini#418
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
File.Reload()parsed every data source on top of the sections already in memory, so nothing that had been removed from the source ever went away:Reload()(the case in Reload retains keys removed from the source file #418);AllowNonUniqueSections, everyReload()appended another copy of every section,DEFAULTincluded ([DEFAULT peer peer]→[DEFAULT peer peer DEFAULT peer peer]).Reload()now clears the sections before parsing the sources again, so the result matches what loading the sources from scratch gives. The parsing loop moved into an unexportedloadSources(), whichAppend()keeps calling as before, soAppend()still merges on top of the current sections and anything created in memory before anAppend()is not lost.The only behaviour change is that
Reload()now discards in-memory edits, which matches what reloading means; the doc comment says so.Link to the issue: #418
Checklist
Tests:
TestReloadDropsRemovedKeysAndSectionsandTestReloadDoesNotDuplicateNonUniqueSectionsfail before the change and pass after it.go test -race ./...andgo vet ./...pass, and the existingTestReloadAfterShadowLoad(#207) still passes.