Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions syncserver/src/web/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ pub async fn get_collection(
};
let response = if coll.query.full {
let result = db.get_bsos(params).await;
finish_get_collection(&coll, db, result).await?
finish_get_collection(&coll, result).await?
} else {
// Changed to be a Paginated list of BSOs, need to extract IDs from them.
let result = db.get_bso_ids(params).await;
finish_get_collection(&coll, db, result).await?
finish_get_collection(&coll, result).await?
};
Ok(response)
})
Expand All @@ -331,7 +331,6 @@ pub async fn get_collection(

async fn finish_get_collection<T>(
coll: &CollectionRequest,
db: &mut dyn Db<Error = DbError>,
result: Result<Paginated<T>, DbError>,
) -> Result<HttpResponse, DbError>
where
Expand All @@ -347,14 +346,8 @@ where
}
})?;

let ts = db
.extract_resource(coll.user_id.clone(), Some(coll.collection.clone()), None)
.await?;

let mut builder = HttpResponse::build(StatusCode::OK);
let resp = builder
.insert_header((X_LAST_MODIFIED, ts.as_header()))
.insert_header((X_WEAVE_RECORDS, result.items.len().to_string()));
let resp = builder.insert_header((X_WEAVE_RECORDS, result.items.len().to_string()));

if let Some(offset) = result.offset {
resp.insert_header((X_WEAVE_NEXT_OFFSET, offset));
Expand Down
10 changes: 4 additions & 6 deletions syncserver/src/web/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@ impl DbTransactionPool {

let mut resp = action(db).await?;

if resp.headers().contains_key(X_LAST_MODIFIED) {
return Ok(resp);
}

// See if we already extracted one and use that if possible
if let Ok(ts_header) = header::HeaderValue::from_str(&resource_ts.as_header()) {
trace!("📝 Setting X-Last-Modfied {:?}", ts_header);
if !resp.headers().contains_key(X_LAST_MODIFIED)
&& let Ok(ts_header) = HeaderValue::from_str(&resource_ts.as_header())
{
trace!("📝 Setting X-Last-Modfied {ts_header:?}");
resp.headers_mut()
.insert(header::HeaderName::from_static(X_LAST_MODIFIED), ts_header);
}
Expand Down