Browse Source

Merge branch 'improve/mastodon-api-cache' of foxhkron/kibou into master

master
Toromino 4 months ago
parent
commit
ac7a86a8d4
3 changed files with 5 additions and 5 deletions
  1. 1
    0
      src/bin/kibou_server.rs
  2. 1
    4
      src/database/mod.rs
  3. 3
    1
      src/mastodon_api/controller.rs

+ 1
- 0
src/bin/kibou_server.rs View File

@@ -9,6 +9,7 @@ fn main() {
9 9
             .expect("Unknown ROCKET_ENV value! (enum: {Development, Staging, Production})"),
10 10
     )
11 11
     .address(env::get_value("endpoint.host".to_string()))
12
+    .log_level(rocket::config::LoggingLevel::Normal)
12 13
     .port(
13 14
         env::get_value("endpoint.port".to_string())
14 15
             .parse::<u16>()

+ 1
- 4
src/database/mod.rs View File

@@ -34,12 +34,9 @@ impl std::ops::Deref for PooledConnection {
34 34
     }
35 35
 }
36 36
 
37
-#[deprecated]
38 37
 pub fn establish_connection() -> PooledConnection {
39 38
     // Originally this always established a new database connection, now this is just gonna
40
-    // return a new connection from the pool until this function can be removed completely.
41
-    //
42
-    // TODO: Remove all references of this function!
39
+    // return a new connection from the pool.
43 40
 
44 41
     return PooledConnection(POOL.get().unwrap());
45 42
 }

+ 3
- 1
src/mastodon_api/controller.rs View File

@@ -172,7 +172,9 @@ pub fn cached_notifications(pooled_connection: &PooledConnection, ids: Vec<i64>)
172 172
 }
173 173
 
174 174
 pub fn cached_statuses(pooled_connection: &PooledConnection, ids: Vec<i64>) -> JsonValue {
175
-    let mut status_cache = MASTODON_API_STATUS_CACHE.lock().unwrap();
175
+    // Try to ignore mutex poisoning, the mutex might already get poisened once a status fails to
176
+    // serialize.
177
+    let mut status_cache = MASTODON_API_STATUS_CACHE.lock().unwrap_or_else(|e| e.into_inner());
176 178
     let mut statuses: Vec<Status> = Vec::new();
177 179
     let mut uncached_statuses: Vec<i64> = Vec::new();
178 180
     for id in ids {

Loading…
Cancel
Save