2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 03:11:24 +00:00

replace remaining web::block with spawn_blocking

This commit is contained in:
asonix 2024-01-30 14:16:05 -06:00
parent 378bde933e
commit dc12f6f79d
2 changed files with 7 additions and 7 deletions

View file

@ -210,7 +210,7 @@ impl ProxyRepo for SledRepo {
let proxy = self.proxy.clone();
let inverse_proxy = self.inverse_proxy.clone();
actix_web::web::block(move || {
crate::sync::spawn_blocking("sled-io", move || {
proxy.insert(url.as_str().as_bytes(), alias.to_bytes())?;
inverse_proxy.insert(alias.to_bytes(), url.as_str().as_bytes())?;
@ -232,7 +232,7 @@ impl ProxyRepo for SledRepo {
let proxy = self.proxy.clone();
let inverse_proxy = self.inverse_proxy.clone();
actix_web::web::block(move || {
crate::sync::spawn_blocking("sled-io", move || {
if let Some(url) = inverse_proxy.remove(alias.to_bytes())? {
proxy.remove(url)?;
}
@ -1215,7 +1215,7 @@ impl HashRepo for SledRepo {
let hash = hash.to_ivec();
let res = actix_web::web::block(move || {
let res = crate::sync::spawn_blocking("sled-io", move || {
(&hashes, &hashes_inverse, &hash_identifiers).transaction(
|(hashes, hashes_inverse, hash_identifiers)| {
if hashes.get(hash.clone())?.is_some() {
@ -1395,7 +1395,7 @@ impl HashRepo for SledRepo {
Ok(v) as Result<Vec<_>, SledError>
});
let res = actix_web::web::block(move || {
let res = crate::sync::spawn_blocking("sled-io", move || {
(
&hashes,
&hashes_inverse,
@ -1462,7 +1462,7 @@ impl AliasRepo for SledRepo {
let hash_aliases = self.hash_aliases.clone();
let alias_delete_tokens = self.alias_delete_tokens.clone();
let res = actix_web::web::block(move || {
let res = crate::sync::spawn_blocking("sled-io", move || {
(&aliases, &alias_hashes, &hash_aliases, &alias_delete_tokens).transaction(
|(aliases, alias_hashes, hash_aliases, alias_delete_tokens)| {
if aliases.get(&alias)?.is_some() {
@ -1539,7 +1539,7 @@ impl AliasRepo for SledRepo {
let hash_aliases = self.hash_aliases.clone();
let alias_delete_tokens = self.alias_delete_tokens.clone();
let res = actix_web::web::block(move || {
let res = crate::sync::spawn_blocking("sled-io", move || {
(&aliases, &alias_hashes, &hash_aliases, &alias_delete_tokens).transaction(
|(aliases, alias_hashes, hash_aliases, alias_delete_tokens)| {
aliases.remove(&alias)?;

View file

@ -613,7 +613,7 @@ impl ObjectStore {
let length = buf.len();
let hashing_span = tracing::debug_span!("Hashing request body");
let hash_string = actix_web::web::block(move || {
let hash_string = crate::sync::spawn_blocking("hash-buf", move || {
let guard = hashing_span.enter();
let mut hasher = md5::Md5::new();
for bytes in buf {