Clean up after #52 and #58#59
Merged
Merged
Conversation
dfed
commented
Mar 11, 2022
| // If the application crashes between writing this header and writing the next message data, we'll have only lost the messages we were about to delete. | ||
| // If `writer.offsetInFile == FileHeader.expectedEndOfHeaderInFile`, then crashing before we update the header would lead to this now-empty file being viewed as corrupted. | ||
| try header.updateOffsetInFileAtEndOfNewestMessage(to: writer.offsetInFile) | ||
| reader.offsetInFileAtEndOfNewestMessage = writer.offsetInFile |
Owner
Author
There was a problem hiding this comment.
We determined that these lines were duplicative – our header is always set to where the writer.offsetInFile is at this stage.
dfed
commented
Mar 11, 2022
| @@ -62,9 +62,6 @@ final class CacheReader { | |||
| case .emptyRead: | |||
| guard !previousReadWasEmpty else { | |||
| // If the previous read was also empty, then the file has been corrupted. | |||
Owner
Author
There was a problem hiding this comment.
This comment is still correct
dfed
commented
Mar 11, 2022
| // If the previous read was also empty, then the file has been corrupted. | ||
| // Two empty reads in a row means that offsetInFileAtEndOfNewestMessage is incorrect. | ||
| // This inconsistency is likely due to a crash occurring during a message write, between truncating the file and updating the header values to reflect that the file was truncated. | ||
| // This file is actually empty, despite what the header tells us. |
Owner
Author
There was a problem hiding this comment.
We've determined that our attribution of how the file got corrupted is incorrect. Since we don't know how this happened, we are deleting the explanation.
dfed
commented
Mar 11, 2022
| XCTAssertEqual( | ||
| UInt64(createFileHeader().asData.count), | ||
| FileHeader.expectedEndOfHeaderInFile) | ||
| } |
Owner
Author
There was a problem hiding this comment.
seems like a good test to have
bachand
approved these changes
Mar 15, 2022
bachand
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for cleaning up. Even though this PR wasn't marked ready for review I reviewed it since I believe it's done.
Owner
Author
|
Oops. Thanks for the review Michael: you were right that this PR was indeed done. |
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.
Wrapping up some good discussions from #52 and #58