mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
fixed overflow when empty page
This commit is contained in:
parent
c9b26031e2
commit
0dd73e693e
|
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Missing `FLAGS` column in messages table [#40]
|
||||
- Subtract with overflow if next page empty [#38]
|
||||
|
||||
## [0.2.0] - 2021-03-10
|
||||
|
||||
|
@ -80,5 +81,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#25]: https://github.com/soywod/himalaya/issues/25
|
||||
[#29]: https://github.com/soywod/himalaya/issues/29
|
||||
[#32]: https://github.com/soywod/himalaya/issues/32
|
||||
[#38]: https://github.com/soywod/himalaya/issues/38
|
||||
[#39]: https://github.com/soywod/himalaya/issues/39
|
||||
[#40]: https://github.com/soywod/himalaya/issues/40
|
||||
|
|
12
src/imap.rs
12
src/imap.rs
|
@ -101,10 +101,16 @@ impl<'a> ImapConnector<'a> {
|
|||
.sess
|
||||
.select(mbox)
|
||||
.chain_err(|| format!("Cannot select mailbox `{}`", mbox))?
|
||||
.exists;
|
||||
.exists as i64;
|
||||
|
||||
let begin = last_seq - page * page_size;
|
||||
let end = begin - (begin - 1).min(page_size - 1);
|
||||
if last_seq == 0 {
|
||||
return Err(format!("Cannot select empty mailbox `{}`", mbox).into());
|
||||
}
|
||||
|
||||
// TODO: add tests, improve error management when empty page
|
||||
let cursor = (page * page_size) as i64;
|
||||
let begin = 1.max(last_seq - cursor);
|
||||
let end = begin - begin.min(*page_size as i64) + 1;
|
||||
let range = format!("{}:{}", begin, end);
|
||||
|
||||
let msgs = self
|
||||
|
|
Loading…
Reference in a new issue