mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-11-10 13:51:08 +08:00
FoundationDB fixes
This commit is contained in:
parent
1e908f7737
commit
cf6765b70d
3 changed files with 4 additions and 8 deletions
|
|
@ -202,10 +202,6 @@ impl<T, E: Display> UnwrapResult<T> for Result<T, E> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait TableName {
|
|
||||||
fn table_name(&self) -> &'static str;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn read_file(path: &str) -> Vec<u8> {
|
pub fn read_file(path: &str) -> Vec<u8> {
|
||||||
if path == "-" {
|
if path == "-" {
|
||||||
let mut stdin = std::io::stdin().lock();
|
let mut stdin = std::io::stdin().lock();
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ impl ReadVersion {
|
||||||
pub fn new(version: i64) -> Self {
|
pub fn new(version: i64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
version,
|
version,
|
||||||
expires: Instant::now() + Duration::from_secs(60 * 2),
|
expires: Instant::now() + Duration::from_secs(1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,18 +142,18 @@ impl FdbStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn read_trx(&self) -> crate::Result<Transaction> {
|
pub(crate) async fn read_trx(&self) -> crate::Result<Transaction> {
|
||||||
let trx = self.db.create_trx()?;
|
|
||||||
let (is_expired, mut read_version) = {
|
let (is_expired, mut read_version) = {
|
||||||
let version = self.version.lock();
|
let version = self.version.lock();
|
||||||
(version.is_expired(), version.version)
|
(version.is_expired(), version.version)
|
||||||
};
|
};
|
||||||
|
let trx = self.db.create_trx()?;
|
||||||
|
|
||||||
if is_expired {
|
if is_expired {
|
||||||
read_version = trx.get_read_version().await?;
|
read_version = trx.get_read_version().await?;
|
||||||
*self.version.lock() = ReadVersion::new(read_version);
|
*self.version.lock() = ReadVersion::new(read_version);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
trx.set_read_version(read_version);
|
trx.set_read_version(read_version);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(trx)
|
Ok(trx)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue