mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 13:17:55 +08:00
fixed overflow when empty page
This commit is contained in:
@@ -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
|
||||
|
||||
+9
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user