v0.25.2
This commit is contained in:
1 parent
59ddabb72b
commit
174389e5b1
48 files changed
+688
-212
No files matched your search
+9
-4
@@ -43,14 +43,19 @@ pub fn prepare_directory(path: &Path) -> Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn lock_directory(path: &Path) -> Result<File> {
|
||||
pub fn try_lock_directory(path: &Path) -> Result<Option<File>> {
|
||||
let file = private_options()
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(path.join("process.lock"))?;
|
||||
file.try_lock_exclusive()
|
||||
.context("another RustProxy process already owns this data directory")?;
|
||||
Ok(file)
|
||||
match file.try_lock_exclusive() {
|
||||
Ok(()) => Ok(Some(file)),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => Ok(None),
|
||||
Err(error) => Err(error).context("could not lock RustProxy data directory"),
|
||||
}
|
||||
}
|
||||
pub fn lock_directory(path: &Path) -> Result<File> {
|
||||
try_lock_directory(path)?.context("another RustProxy process already owns this data directory")
|
||||
}
|
||||
pub fn load_setup_token(dir: &Path) -> Result<String> {
|
||||
let path = dir.join("setup-token");
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ use argon2::{
|
||||
Algorithm, Argon2, Params, Version,
|
||||
};
|
||||
pub use files::{
|
||||
load_or_create_setup_token, load_setup_token, lock_directory, prepare_database,
|
||||
load_or_create_setup_token, load_setup_token, lock_directory, prepare_database, try_lock_directory,
|
||||
prepare_directory,
|
||||
};
|
||||
use http::{header::COOKIE, HeaderMap, StatusCode};
|
||||
|
||||
Reference in new issue
Block a user