aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/Cargo.toml3
-rw-r--r--src/model/garage.rs2
-rw-r--r--src/model/helper/locked.rs9
-rw-r--r--src/model/k2v/causality.rs6
-rw-r--r--src/model/k2v/rpc.rs2
-rw-r--r--src/model/s3/lifecycle_worker.rs6
6 files changed, 12 insertions, 16 deletions
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 12931a4c..b58ad43b 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -22,7 +22,6 @@ garage_util.workspace = true
garage_net.workspace = true
async-trait.workspace = true
-arc-swap.workspace = true
blake2.workspace = true
chrono.workspace = true
err-derive.workspace = true
@@ -38,9 +37,7 @@ serde.workspace = true
serde_bytes.workspace = true
futures.workspace = true
-futures-util.workspace = true
tokio.workspace = true
-opentelemetry.workspace = true
[features]
default = [ "lmdb", "sqlite" ]
diff --git a/src/model/garage.rs b/src/model/garage.rs
index 29e0bddd..11c0d90f 100644
--- a/src/model/garage.rs
+++ b/src/model/garage.rs
@@ -329,7 +329,7 @@ impl Garage {
pub async fn locked_helper(&self) -> helper::locked::LockedHelper {
let lock = self.bucket_lock.lock().await;
- helper::locked::LockedHelper(self, lock)
+ helper::locked::LockedHelper(self, Some(lock))
}
}
diff --git a/src/model/helper/locked.rs b/src/model/helper/locked.rs
index 43f4f363..482e91b0 100644
--- a/src/model/helper/locked.rs
+++ b/src/model/helper/locked.rs
@@ -27,9 +27,16 @@ use crate::permission::BucketKeyPerm;
/// See issues: #649, #723
pub struct LockedHelper<'a>(
pub(crate) &'a Garage,
- pub(crate) tokio::sync::MutexGuard<'a, ()>,
+ pub(crate) Option<tokio::sync::MutexGuard<'a, ()>>,
);
+impl<'a> Drop for LockedHelper<'a> {
+ fn drop(&mut self) {
+ // make it explicit that the mutexguard lives until here
+ drop(self.1.take())
+ }
+}
+
#[allow(clippy::ptr_arg)]
impl<'a> LockedHelper<'a> {
pub fn bucket(&self) -> BucketHelper<'a> {
diff --git a/src/model/k2v/causality.rs b/src/model/k2v/causality.rs
index c80ebd39..7d311ede 100644
--- a/src/model/k2v/causality.rs
+++ b/src/model/k2v/causality.rs
@@ -16,8 +16,6 @@ use serde::{Deserialize, Serialize};
use garage_util::data::*;
-use crate::helper::error::{Error as HelperError, OkOrBadRequest};
-
/// Node IDs used in K2V are u64 integers that are the abbreviation
/// of full Garage node IDs which are 256-bit UUIDs.
pub type K2VNodeId = u64;
@@ -99,10 +97,6 @@ impl CausalContext {
Some(ret)
}
- pub fn parse_helper(s: &str) -> Result<Self, HelperError> {
- Self::parse(s).ok_or_bad_request("Invalid causality token")
- }
-
/// Check if this causal context contains newer items than another one
pub fn is_newer_than(&self, other: &Self) -> bool {
vclock_gt(&self.vector_clock, &other.vector_clock)
diff --git a/src/model/k2v/rpc.rs b/src/model/k2v/rpc.rs
index a1bf6ee0..821f4549 100644
--- a/src/model/k2v/rpc.rs
+++ b/src/model/k2v/rpc.rs
@@ -10,7 +10,6 @@ use std::convert::TryInto;
use std::sync::{Arc, Mutex, MutexGuard};
use std::time::{Duration, Instant};
-use async_trait::async_trait;
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use serde::{Deserialize, Serialize};
@@ -537,7 +536,6 @@ impl K2VRpcHandler {
}
}
-#[async_trait]
impl EndpointHandler<K2VRpc> for K2VRpcHandler {
async fn handle(self: &Arc<Self>, message: &K2VRpc, _from: NodeID) -> Result<K2VRpc, Error> {
match message {
diff --git a/src/model/s3/lifecycle_worker.rs b/src/model/s3/lifecycle_worker.rs
index 38212a1c..bb10ba48 100644
--- a/src/model/s3/lifecycle_worker.rs
+++ b/src/model/s3/lifecycle_worker.rs
@@ -395,13 +395,13 @@ fn midnight_ts(date: NaiveDate, use_local_tz: bool) -> u64 {
.expect("bad local midnight")
.timestamp_millis() as u64;
}
- midnight.timestamp_millis() as u64
+ midnight.and_utc().timestamp_millis() as u64
}
fn next_date(ts: u64) -> NaiveDate {
- NaiveDateTime::from_timestamp_millis(ts as i64)
+ DateTime::<Utc>::from_timestamp_millis(ts as i64)
.expect("bad timestamp")
- .date()
+ .date_naive()
.succ_opt()
.expect("no next day")
}