This commit is contained in:
parent
4db1ac6ff7
commit
a4ea55cf3c
|
@ -116,6 +116,14 @@ impl AppState {
|
|||
Ok(new_path)
|
||||
}
|
||||
|
||||
pub async fn set_path(&self, filename: &str, filepath: &str) {
|
||||
let mut redis = self.redis.clone();
|
||||
let _: () = redis
|
||||
.hset(PATH_MAPPING_KEY, filename, filepath)
|
||||
.await
|
||||
.expect(&format!("Failed to cache file {} in Redis", filename));
|
||||
}
|
||||
|
||||
/// создает или получает текущее значение квоты пользователя
|
||||
pub async fn get_or_create_quota(&self, user_id: &str) -> Result<u64, actix_web::Error> {
|
||||
let mut redis = self.redis.clone();
|
||||
|
|
|
@ -118,6 +118,7 @@ pub async fn proxy_handler(
|
|||
error!("cannot upload to storj: {}", e);
|
||||
} else {
|
||||
warn!("file {} uploaded to storj", filekey);
|
||||
state.set_path(&filekey, &filekey).await;
|
||||
}
|
||||
let _ = thumbdata_save(filedata.clone(), &state, &filekey, content_type.to_string())
|
||||
.await;
|
||||
|
@ -170,6 +171,7 @@ pub async fn proxy_handler(
|
|||
warn!("cannot upload to storj: {}", e);
|
||||
} else {
|
||||
warn!("file {} uploaded to storj", filekey);
|
||||
state.set_path(&filekey, &filepath).await;
|
||||
}
|
||||
Ok(HttpResponse::Ok().content_type(content_type).body(filedata))
|
||||
},
|
||||
|
|
|
@ -72,10 +72,10 @@ pub async fn upload_handler(
|
|||
warn!("cannot upload to storj: {}", e);
|
||||
} else {
|
||||
warn!("file {} uploaded to storj", body);
|
||||
}
|
||||
|
||||
// Сохраняем информацию о загруженном файле для пользователя
|
||||
user_added_file(&mut state.redis.clone(), &user_id, &body).await?;
|
||||
state.set_path(&body, &body).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(HttpResponse::Ok().body(body))
|
||||
|
|
|
@ -159,8 +159,6 @@ pub async fn thumbdata_save(
|
|||
.await
|
||||
{
|
||||
warn!("cannot load thumb {}: {}", thumb_filename, e);
|
||||
} else {
|
||||
warn!("thumb {} uploaded to storj", thumb_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user