feat: persist I2P torrent list to EDN state file across restarts
- Save active and paused torrents to torrents.edn on add, remove, pause, resume, and metadata fetch, then restore them on router startup. - Default path is $MOON_I2P_DATA_DIR, then $XDG_DATA_HOME, then ~/.local/share/moon-i2p-browser. Add --torrent-state <file> to override, or --no-torrent-state to disable. - Write the state file atomically (temp file, fsync, rename). A corrupt or unsupported file logs a warning and does not block startup. - Verify restored pieces incrementally in the background for large torrents; these show as state "checking" in /api/torrents. - Expose state_file in /api/status and the startup banner. - Add standard RFC 4648 Base64 encode/decode helpers, used for the info-b64 field. - Add the moonedn dependency and pass --torrent-state from the Android service.
This commit is contained in:
1 parent
b803e79199
commit
dd5b132b5a
17 files changed
+1105
-39
No files matched your search
@@ -122,3 +122,37 @@ test "crc32, gzip dynamic Huffman inflate, deflate/gzip round-trip, I2CP mux, an
|
||||
assert_eq(zip_entries[1].1.length(), 940)
|
||||
assert_eq(@encoding.crc32(zip_entries[1].1), 0x51eab753U)
|
||||
}
|
||||
|
||||
///|
|
||||
test "standard RFC 4648 base64 uses + and / and round-trips" {
|
||||
let raw = b"\xfb\xff\xfe"
|
||||
let encoded = @encoding.base64_std_encode(raw)
|
||||
assert_eq(encoded, "+//+")
|
||||
assert_eq(@encoding.base64_std_decode(encoded), raw)
|
||||
|
||||
let cases : Array[(Bytes, String)] = [
|
||||
(b"", ""),
|
||||
(b"f", "Zg=="),
|
||||
(b"fo", "Zm8="),
|
||||
(b"foo", "Zm9v"),
|
||||
(b"foob", "Zm9vYg=="),
|
||||
(b"fooba", "Zm9vYmE="),
|
||||
(b"foobar", "Zm9vYmFy"),
|
||||
]
|
||||
for item in cases {
|
||||
let (bytes, expected) = item
|
||||
assert_eq(@encoding.base64_std_encode(bytes), expected)
|
||||
assert_eq(@encoding.base64_std_decode(expected), bytes)
|
||||
}
|
||||
assert_eq(@encoding.base64_std_decode(" +//+ \n"), raw)
|
||||
|
||||
// I2P alphabet '-' / '~' is rejected by standard Base64 decoder
|
||||
let mut bad_rejected = false
|
||||
let _ = @encoding.base64_std_decode("-~~-") catch {
|
||||
_ => {
|
||||
bad_rejected = true
|
||||
b""
|
||||
}
|
||||
}
|
||||
assert_true(bad_rejected)
|
||||
}
|
||||
Reference in new issue
Block a user