Skip to content

Feat/resumable downloads and dc auth cache - #368

Open
TheLastFlame wants to merge 5 commits into
monogram-android:developfrom
TheLastFlame:feat/resumable-downloads-and-dc-auth-cache
Open

TheLastFlame wants to merge 5 commits into
monogram-android:developfrom
TheLastFlame:feat/resumable-downloads-and-dc-auth-cache

Conversation

@TheLastFlame

Copy link
Copy Markdown
Contributor

@gdlbo
gdlbo requested a balanced review from Copilot and removed request for Copilot October 11, 2026 07:58
@gdlbo
gdlbo requested a balanced review from Copilot October 11, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Resume integrity, staging concurrency, auth-cache isolation, and policy propagation contain blocking correctness and security issues.

4 open findings
What changed in this PR

Adds resumable MTProto media downloads and caches foreign-DC authorization state to reduce repeated setup.

Changes:

  • Persists partial downloads with Nekogram-compatible sidecars.
  • Caches permanent and temporary DC authorization keys.
  • Expands configurable download concurrency.
File Description
native/​mtproto-rs/​tests/​unit/​media_download_tests.rs Updates staging and metadata tests.
native/​mtproto-rs/​tests/​unit/​lib_tests.rs Initializes DC auth cache in fixtures.
native/​mtproto-rs/​tests/​unit/​client_mgr_logout_tests.rs Updates logout fixture state.
native/​mtproto-rs/​tests/​unit/​client_mgr_channel_tests.rs Updates channel fixture state.
native/​mtproto-rs/​src/​transfer_policy.rs Removes the large-download limit cap.
native/​mtproto-rs/​src/​session_file.rs Persists foreign-DC auth keys.
native/​mtproto-rs/​src/​media/​download.rs Implements resumable staging and sidecars.
native/​mtproto-rs/​src/​ffi.rs Connects concurrency settings to queue limits.
native/​mtproto-rs/​src/​client/​session.rs Reuses cached foreign-DC authorization.
native/​mtproto-rs/​src/​client/​persist.rs Saves DC auth caches.
native/​mtproto-rs/​src/​client/​mod.rs Adds permanent and temporary auth caches.
native/​mtproto-rs/​src/​client/​media_download.rs Reuses bound temporary auth sessions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

let session_meta_changed = before_new_session != state.new_session
|| before_dead != state.session_dead
|| before_test_dc != state.test_dc;
let dc_keys_changed = before_dc_auth_keys != state.dc_auth_keys;
Comment on lines +638 to +640
let mut temp_name = destination.as_os_str().to_os_string();
temp_name.push(".temp");
let path = PathBuf::from(temp_name);
let lanes_cnt = lanes.max(1) as usize;
scheduler::set_active_media_lanes(lanes_cnt);
client::set_pipeline_parts(parts.max(1) as usize);
*crate::transfer_policy::current().queue_limits.lock() = (lanes_cnt, lanes_cnt);
Comment on lines +596 to +598
let count = i32::from_be_bytes(bytes[0..4].try_into().ok()?) as usize;
if bytes.len() != 4 + count * 16 {
return None;

This branch has not been deployed

No deployments
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.

2 participants