Repository navigation
Conversation
Comment on lines
+113
to
+123
| if let Some((base, date)) = s.rsplit_once('-') { | ||
| if date.len() == 8 | ||
| && date.bytes().all(|b| b.is_ascii_digit()) | ||
| && Uuid::parse_str(base).is_ok() | ||
| { | ||
| let digest = Sha1::digest(s.as_bytes()); | ||
| let mut bytes = [0u8; 16]; | ||
| bytes.copy_from_slice(&digest[..16]); | ||
| return Ok(ThingsId(bytes)); | ||
| } | ||
| } |
Owner
There was a problem hiding this comment.
nit and maybe clippy will catch, but I think you could write this as
Suggested change
| if let Some((base, date)) = s.rsplit_once('-') { | |
| if date.len() == 8 | |
| && date.bytes().all(|b| b.is_ascii_digit()) | |
| && Uuid::parse_str(base).is_ok() | |
| { | |
| let digest = Sha1::digest(s.as_bytes()); | |
| let mut bytes = [0u8; 16]; | |
| bytes.copy_from_slice(&digest[..16]); | |
| return Ok(ThingsId(bytes)); | |
| } | |
| } | |
| if let Some((base, date)) = s.rsplit_once('-') | |
| && date.len() == 8 | |
| && date.bytes().all(|b| b.is_ascii_digit()) | |
| && Uuid::parse_str(base).is_ok() | |
| { | |
| let digest = Sha1::digest(s.as_bytes()); | |
| let mut bytes = [0u8; 16]; | |
| bytes.copy_from_slice(&digest[..16]); | |
| return Ok(ThingsId(bytes)); | |
| } |
via let chains https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/#let-chains
Owner
|
Thanks very much for this fix! If you can address the lint errors we can get this merged! |
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.
Fixes #10.
Accounts with data from old Things versions cannot sync at all. Two legacy ID formats break
ThingsId::from_str, and a single bad entry aborts the whole append-log fold:CC-Things-Tag-Office(and Errand, Home, Important, Pending): built-in tag IDs, appear intgfields.<UUID>-<YYYYMMDD>: materialized recurring-task instance IDs, template UUID plus instance date. Appear as object keys and in tombstonedloidfields.Repro: run
things3 today(any command that syncs) against such an account. It fails with e.g.Corrupt log entry at .../things.log byte 42872: invalid Things ID: "CC-Things-Tag-Office".The fix canonicalizes both formats the same way
ACTIONGROUP-IDs already are: digest the full string with SHA1 truncated to 16 bytes, so entity keys and references agree deterministically. For the instance form it only applies when the base parses as a UUID and the suffix is exactly 8 digits, so genuinely malformed IDs still error. Instances stay distinct from each other and from their template (the template link travels in thertfield as a bare UUID).Tests: 6 new unit tests covering determinism, distinctness, serde roundtrip, and rejection of bad inputs. Full suite passes (
cargo test --locked).One caveat: unlike
ACTIONGROUP-, there is no bare-UUID form the server recognizes for these IDs, so writes would re-encode the digested form. Reads are unaffected.