mirror of
https://github.com/flibusta-apps/library_updater.git
synced 2025-12-06 07:45:35 +01:00
Add update lock
This commit is contained in:
@@ -27,7 +27,7 @@ async fn update(headers: HeaderMap) -> &'static str {
|
|||||||
match updater::update().await {
|
match updater::update().await {
|
||||||
Ok(_) => log::info!("Updated!"),
|
Ok(_) => log::info!("Updated!"),
|
||||||
Err(err) => log::info!("Updater err: {:?}", err),
|
Err(err) => log::info!("Updater err: {:?}", err),
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
"Update started"
|
"Update started"
|
||||||
|
|||||||
@@ -259,7 +259,16 @@ async fn send_webhooks() -> Result<(), Box<reqwest::Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref UPDATE_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::new(());
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn update() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn update() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let _lock = match UPDATE_LOCK.try_lock() {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(err) => return Err(Box::new(err)),
|
||||||
|
};
|
||||||
|
|
||||||
log::info!("Start update...");
|
log::info!("Start update...");
|
||||||
|
|
||||||
let pool = match get_postgres_pool().await {
|
let pool = match get_postgres_pool().await {
|
||||||
|
|||||||
Reference in New Issue
Block a user