Skip to content

Commit 40a7c34

Browse files
author
Nathan Monfils
committed
Fix deprecated explicit file lock mode
Signed-off-by: Nathan Monfils <nathan.monfils@destiny.eu>
1 parent ed2e97e commit 40a7c34

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

core-dump-agent/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate dotenv;
22
extern crate s3;
33

4-
use advisory_lock::{AdvisoryFileLock, FileLockMode};
54
use env_logger::Env;
65
use inotify::{EventMask, Inotify, WatchMask};
76
use log::{error, info, warn};
@@ -314,7 +313,7 @@ async fn process_file(zip_path: &Path, bucket: &Bucket) -> Result<(), String> {
314313

315314
let f = File::open(zip_path).expect("no file found");
316315

317-
match f.try_lock(FileLockMode::Shared) {
316+
match f.try_lock_shared() {
318317
Ok(_) => { /* If we can lock then we are ok */ }
319318
Err(e) => {
320319
let l_inotify = env::var("USE_INOTIFY")

core-dump-composer/src/events.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::config::CoreParams;
2-
use advisory_lock::{AdvisoryFileLock, FileLockMode};
32
use serde::Serialize;
43
use serde_json::Value;
54
use std::collections::HashMap;
@@ -87,7 +86,7 @@ impl CoreEvent {
8786
pub fn write_event(&self, eventlocation: &str) -> Result<(), anyhow::Error> {
8887
let full_path = format!("{}/{}-event.json", eventlocation, self.uuid);
8988
let file = File::create(full_path)?;
90-
file.lock(FileLockMode::Exclusive)?;
89+
file.lock()?;
9190
serde_json::to_writer(&file, &self)?;
9291
file.unlock()?;
9392
Ok(())

core-dump-composer/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ extern crate dotenv;
22

33
use crate::events::CoreEvent;
44

5-
use advisory_lock::{AdvisoryFileLock, FileLockMode};
65
use libcrio::Cli;
76
use log::{debug, error, info, warn};
87
use serde_json::json;
@@ -131,7 +130,7 @@ fn handle(mut cc: config::CoreConfig) -> Result<(), anyhow::Error> {
131130
process::exit(1);
132131
}
133132
};
134-
file.lock(FileLockMode::Exclusive)?;
133+
file.lock()?;
135134
let mut zip = ZipWriter::new(&file);
136135

137136
debug!(

0 commit comments

Comments
 (0)