From cd5226adc2f64a1582041e958c8c93dd60ba422e Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Thu, 21 Aug 2025 21:12:41 -0700 Subject: [PATCH] net: Fix initial indexeddb version storage (#38836) #38819 made a step in the right direction. Unfortunately sqlite doesn't support unsigned integers, so I've been storing them as i64s internally, but deserializing the bytes to u64s. This allows for an extra bit of information, but by inserting 0 into the table, it was interpreted `u64::from_ne_bytes([1,0,0,0....,0])` (or whatever the internal bit representation of `0_i64` is on the platform), which is not intended. Signed-off-by: Ashwin Naren --- components/net/indexeddb/engines/sqlite.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/net/indexeddb/engines/sqlite.rs b/components/net/indexeddb/engines/sqlite.rs index 8e76c9ce46c..a96082a2189 100644 --- a/components/net/indexeddb/engines/sqlite.rs +++ b/components/net/indexeddb/engines/sqlite.rs @@ -125,10 +125,11 @@ impl SqliteEngine { // From https://w3c.github.io/IndexedDB/#database-version: // "When a database is first created, its version is 0 (zero)." connection.execute( - "INSERT INTO database (name, origin, version) VALUES (?, ?, 0)", + "INSERT INTO database (name, origin, version) VALUES (?, ?, ?)", params![ db_info.name.to_owned(), db_info.origin.to_owned().ascii_serialization(), + i64::from_ne_bytes(0_u64.to_ne_bytes()) ], )?; Ok(connection)