Skip to content

Commit

Permalink
fix: read directory returned error when there is no preference set
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlimjustin committed Dec 4, 2021
1 parent 5e5b4a6 commit e508a32
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src-tauri/src/files_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,15 @@ pub async fn read_directory(dir: &Path) -> Result<FolderInformation, String> {
Ok(result) => result,
Err(_) => return Err("Error reading preference".into()),
};
let preference = if preference.status {
let preference = if preference.status || preference.data == serde_json::Value::Null {
preference.data
} else {
return Err("Error reading preference".into());
};
let hide_system_files = preference["hideSystemFiles"].as_bool().unwrap_or(true);
let hide_system_files = match preference {
serde_json::Value::Null => true,
_ => preference["hideSystemFiles"].as_bool().unwrap_or(true),
};
let paths = fs::read_dir(dir).map_err(|err| err.to_string())?;
let mut number_of_files: u16 = 0;
let mut files = Vec::new();
Expand Down

1 comment on commit e508a32

@vercel
Copy link

@vercel vercel bot commented on e508a32 Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.