Remove unused `timestamp` from Sync15StorageClient
Also add a test ensuring it's Send. We don't need this anymore, but we will in the future.
This commit is contained in:
Родитель
caff00d3d0
Коммит
d91ced8903
|
@ -7,7 +7,7 @@ use crate::error::{self, ErrorKind};
|
|||
use crate::record_types::MetaGlobalRecord;
|
||||
use crate::request::{
|
||||
BatchPoster, CollectionRequest, InfoCollections, InfoConfiguration, PostQueue, PostResponse,
|
||||
PostResponseHandler, X_IF_UNMODIFIED_SINCE, X_WEAVE_TIMESTAMP,
|
||||
PostResponseHandler, X_IF_UNMODIFIED_SINCE,
|
||||
};
|
||||
use crate::token;
|
||||
use crate::util::ServerTimestamp;
|
||||
|
@ -16,8 +16,6 @@ use reqwest::{
|
|||
header::{self, HeaderValue, ACCEPT, AUTHORIZATION},
|
||||
Client, Request, Response, Url,
|
||||
};
|
||||
use std::cell::Cell;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -43,8 +41,6 @@ pub trait SetupStorageClient {
|
|||
#[derive(Debug)]
|
||||
pub struct Sync15StorageClient {
|
||||
http_client: Client,
|
||||
// We update this when we make requests
|
||||
timestamp: Cell<ServerTimestamp>,
|
||||
tsc: token::TokenProvider,
|
||||
}
|
||||
|
||||
|
@ -106,19 +102,12 @@ impl Sync15StorageClient {
|
|||
init_params.access_token,
|
||||
init_params.key_id,
|
||||
);
|
||||
let timestamp = ServerTimestamp(0f64);
|
||||
Ok(Sync15StorageClient {
|
||||
http_client: client,
|
||||
timestamp: Cell::new(timestamp),
|
||||
tsc,
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn last_server_time(&self) -> ServerTimestamp {
|
||||
return self.timestamp.get();
|
||||
}
|
||||
|
||||
pub fn get_encrypted_records(
|
||||
&self,
|
||||
collection_request: &CollectionRequest,
|
||||
|
@ -169,8 +158,6 @@ impl Sync15StorageClient {
|
|||
let resp = self.http_client.execute(req)?;
|
||||
log::trace!("response: {}", resp.status());
|
||||
|
||||
self.update_timestamp(resp.headers());
|
||||
|
||||
if require_success && !resp.status().is_success() {
|
||||
log::warn!(
|
||||
"HTTP error {} ({}) during storage request to {}",
|
||||
|
@ -209,19 +196,6 @@ impl Sync15StorageClient {
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
fn update_timestamp(&self, hm: &header::HeaderMap) {
|
||||
if let Some(ts) = hm
|
||||
.get(X_WEAVE_TIMESTAMP)
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.and_then(|s| ServerTimestamp::from_str(s).ok())
|
||||
{
|
||||
self.timestamp.set(ts);
|
||||
} else {
|
||||
// Should we complain more here?
|
||||
log::warn!("No X-Weave-Timestamp from storage server!");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_post_queue<'a, F: PostResponseHandler>(
|
||||
&'a self,
|
||||
coll: &str,
|
||||
|
@ -310,3 +284,14 @@ impl<'a> BatchPoster for PostWrapper<'a> {
|
|||
Ok(PostResponse::from_response(&mut resp)?)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_send() {
|
||||
fn ensure_send<T: Send>() {}
|
||||
// Compile will fail if not send.
|
||||
ensure_send::<Sync15StorageClient>();
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче