Hirevo / mega-rs

An API client library for interacting with MEGA from Rust

Home Page:https://crates.io/crates/mega

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CondensedMacMismatch When Over Quota

jonatino opened this issue · comments

For some reason I've been getting these CondensedMacMismatch errors when in reality I've gone over my daily quota.

Is there an issue with reporting the EOVERQUOTA error? CondensedMacMismatch is kind of misleading.

Hi, thanks for reporting this issue.

The CondensedMacMismatch error happens when the MAC checksum of the file (stored in MEGA) doesn't match with the one we computed as the download was happening.
This check happens directly after the file download has completed (by completed, I mean we've reached EOF from the download stream, and there is no more bytes to be read).

Since we currently download the whole file in a single request (rather than using one request per chunk), the fact that the EOVERQUOTA error is not showing up may be because the download stream is just abruptly closed by the server, and that we currently interpret this stream closure as the end of the download (since it just looks like an EOF to us).

I guess we have two main ways of solving this:

  • Keep track of the number of bytes we've received, and detect if the download stream is closed too early.
  • Download the file in chunks (using one request per chunk), as in that case, MEGA would likely communicate the EOVERQUOTA error in the next chunk request.

I think the second solution is the way to go, as it is closer to how MEGAcmd does it, and it would lay the ground work for eventually download chunks in parallel.

I'll get around to do this work as soon as I can, sorry for the confusion this issue may have caused you.

@Hirevo thanks for the info! I think the second option would be the best for long term solution. Perhaps it will allow other MegaErrors on top of EOVERQUOTA to bubble up properly during the download process.

Look forward to testing the changes. Thank you for writing this crate <3