Skip to content

Fix: use id's to sort persisted diffs instead of file paths#907

Open
tertsdiepraam wants to merge 1 commit into
mainfrom
persist-ids
Open

Fix: use id's to sort persisted diffs instead of file paths#907
tertsdiepraam wants to merge 1 commit into
mainfrom
persist-ids

Conversation

@tertsdiepraam

@tertsdiepraam tertsdiepraam commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This was something I missed during the purging review. I think this is the simplest fix for it. I'm intentionally keeping this very small and self-contained to get the fix in as quickly as possible.

The issue is that the paths get sorted lexicographically so the path se.loaded.10 is sorted before se.loaded.2. To fix this, we store the id as a usize separately and implement Ord by comparing just that field.

Closes #908

Comment thread src/persistence/zone.rs
/// Information about a single persisted zone data file.
#[derive(Clone, Debug)]
pub struct PersistedDiffFileInfo {
id: usize,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
id: usize,
/// Field to order by so that entries in the tree can be iterated over in insertion order.
id: usize,

@ximon18 ximon18 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

During review of PR #657 I was actually against adding an id field to this type, ironically, as it added no value, but now it is being added as a work around for a huge oversight on my part... very appreciated @tertsdiepraam.

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.

Incorrect PersistedDiffFileInfo sort order

2 participants