Commit
+23 -26 +/-1 browse
1 | diff --git a/src/storage/cached.rs b/src/storage/cached.rs |
2 | index acc8809..a8d78e6 100644 |
3 | --- a/src/storage/cached.rs |
4 | +++ b/src/storage/cached.rs |
5 | @@ -27,7 +27,6 @@ use futures::{ |
6 | channel::oneshot, |
7 | future::{self, FutureExt, TryFutureExt}, |
8 | stream::{StreamExt, TryStreamExt}, |
9 | - Future, |
10 | }; |
11 | use humansize::{file_size_opts as file_size, FileSize}; |
12 | use tokio::{self, sync::Mutex}; |
13 | @@ -165,44 +164,42 @@ where |
14 | Ok(deleted) |
15 | } |
16 | |
17 | - fn cache_and_prune<C>( |
18 | + async fn cache_and_prune<C>( |
19 | cache: Arc<C>, |
20 | key: StorageKey, |
21 | obj: LFSObject, |
22 | lru: Arc<Mutex<Cache>>, |
23 | max_size: u64, |
24 | - ) -> impl Future<Output = Result<(), C::Error>> |
25 | + ) -> Result<(), C::Error> |
26 | where |
27 | C: Storage + Send + Sync, |
28 | { |
29 | - async move { |
30 | - let len = obj.len(); |
31 | + let len = obj.len(); |
32 | |
33 | - let oid = *key.oid(); |
34 | + let oid = *key.oid(); |
35 | |
36 | - log::debug!("Caching {}", oid); |
37 | - cache.put(key.clone(), obj).await?; |
38 | - log::debug!("Finished caching {}", oid); |
39 | + log::debug!("Caching {}", oid); |
40 | + cache.put(key.clone(), obj).await?; |
41 | + log::debug!("Finished caching {}", oid); |
42 | |
43 | - // Add the object info to our LRU cache once the download from |
44 | - // permanent storage is complete. |
45 | - { |
46 | - let mut lru = lru.lock().await; |
47 | - lru.push(key, len); |
48 | - } |
49 | - |
50 | - match prune_cache(lru, max_size, cache).await { |
51 | - Ok(count) => { |
52 | - if count > 0 { |
53 | - log::info!("Pruned {} entries from the cache", count); |
54 | - } |
55 | + // Add the object info to our LRU cache once the download from |
56 | + // permanent storage is complete. |
57 | + { |
58 | + let mut lru = lru.lock().await; |
59 | + lru.push(key, len); |
60 | + } |
61 | |
62 | - Ok(()) |
63 | - } |
64 | - Err(err) => { |
65 | - log::error!("Error caching {} ({})", oid, err); |
66 | - Err(err) |
67 | + match prune_cache(lru, max_size, cache).await { |
68 | + Ok(count) => { |
69 | + if count > 0 { |
70 | + log::info!("Pruned {} entries from the cache", count); |
71 | } |
72 | + |
73 | + Ok(()) |
74 | + } |
75 | + Err(err) => { |
76 | + log::error!("Error caching {} ({})", oid, err); |
77 | + Err(err) |
78 | } |
79 | } |
80 | } |