Check for file existence before attempting to open it (#626)

* Check for file existence before attempting to open it

* Fixup
This commit is contained in:
Ana Hobden 2023-09-13 09:55:44 -07:00 committed by GitHub
parent dd36129aa2
commit b3dcf07f58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 4 deletions

View file

@ -266,6 +266,10 @@ impl Action for CreateFile {
buf: _, buf: _,
force: _, force: _,
} = self; } = self;
// The user already deleted it
if !path.exists() {
return Ok(());
}
remove_file(&path) remove_file(&path)
.await .await

View file

@ -339,6 +339,11 @@ impl Action for CreateOrInsertIntoFile {
buf, buf,
position: _, position: _,
} = self; } = self;
// The user already deleted it
if !path.exists() {
return Ok(());
}
let mut file = OpenOptions::new() let mut file = OpenOptions::new()
.create(false) .create(false)
.write(true) .write(true)

View file

@ -104,8 +104,8 @@ impl Planner for Linux {
let Self { settings, init } = self; let Self { settings, init } = self;
let mut map = HashMap::default(); let mut map = HashMap::default();
map.extend(settings.settings()?.into_iter()); map.extend(settings.settings()?);
map.extend(init.settings()?.into_iter()); map.extend(init.settings()?);
Ok(map) Ok(map)
} }

View file

@ -234,7 +234,7 @@ impl Planner for Ostree {
} = self; } = self;
let mut map = HashMap::default(); let mut map = HashMap::default();
map.extend(settings.settings()?.into_iter()); map.extend(settings.settings()?);
map.insert( map.insert(
"persistence".to_string(), "persistence".to_string(),
serde_json::to_value(persistence)?, serde_json::to_value(persistence)?,

View file

@ -360,7 +360,7 @@ impl Planner for SteamDeck {
} = self; } = self;
let mut map = HashMap::default(); let mut map = HashMap::default();
map.extend(settings.settings()?.into_iter()); map.extend(settings.settings()?);
map.insert( map.insert(
"persistence".to_string(), "persistence".to_string(),
serde_json::to_value(persistence)?, serde_json::to_value(persistence)?,