move from try to try_exists for explicit error handling

This commit is contained in:
Oscar Beaumont
2022-10-15 05:18:42 +08:00
parent bea74aede4
commit f140d75ece
7 changed files with 7 additions and 7 deletions

View File

@@ -126,7 +126,7 @@ pub(crate) fn mount() -> rspc::RouterBuilder<
.join(&object.cas_id)
.with_extension("webp");
object.has_thumbnail = thumb_path.exists();
object.has_thumbnail = thumb_path.try_exists().unwrap();
}
ExplorerItem::Path(Box::new(file_path))
})

View File

@@ -61,7 +61,7 @@ pub(crate) fn mount() -> RouterBuilder {
.join(&object.cas_id)
.with_extension("webp");
object.has_thumbnail = thumb_path.exists();
object.has_thumbnail = thumb_path.try_exists().unwrap();
ExplorerItem::Object(Box::new(object))
})

View File

@@ -93,7 +93,7 @@ impl LibraryManager {
};
let db_path = config_path.clone().with_extension("db");
if !db_path.exists() {
if !db_path.try_exists().unwrap() {
println!(
"Found library '{}' but no matching database file was found. Skipping...",
config_path.display()

View File

@@ -44,7 +44,7 @@ impl LocationCreateArgs {
ctx: &LibraryContext,
) -> Result<indexer_job_location::Data, LocationError> {
// check if we have access to this location
if !self.path.exists() {
if !self.path.try_exists().unwrap() {
return Err(LocationError::PathNotFound(self.path));
}

View File

@@ -115,7 +115,7 @@ impl NodeConfigManager {
async fn read(base_path: &PathBuf) -> Result<NodeConfig, NodeConfigError> {
let path = Path::new(base_path).join(NODE_STATE_CONFIG_NAME);
match path.exists() {
match path.try_exists().unwrap() {
true => {
let mut file = File::open(&path)?;
let base_config: ConfigMetadata =

View File

@@ -189,7 +189,7 @@ impl StatefulJob for ThumbnailJob {
let output_path = data.thumbnail_dir.join(&cas_id).with_extension("webp");
// check if file exists at output path
if !output_path.exists() {
if !output_path.try_exists().unwrap() {
info!("Writing {:?} to {:?}", path, output_path);
match step.kind {

View File

@@ -7,7 +7,7 @@ fn main() {
println!("Issuing sdtunnel certificate...");
let env_file = Path::new("./.env");
if env_file.exists() {
if env_file.try_exists().unwrap() {
println!("File '{}' already exists. Exiting...", env_file.display());
return;
}