Make new file/folder an operation
This commit is contained in:
parent
f31f8a0559
commit
01a2e13e56
2 changed files with 40 additions and 15 deletions
15
src/app.rs
15
src/app.rs
|
|
@ -654,17 +654,11 @@ impl Application for App {
|
|||
match dialog_page {
|
||||
DialogPage::NewItem { parent, name, dir } => {
|
||||
let path = parent.join(name);
|
||||
match if dir {
|
||||
fs::create_dir(&path)
|
||||
self.operation(if dir {
|
||||
Operation::NewFolder { path }
|
||||
} else {
|
||||
fs::File::create(&path).map(|_| ())
|
||||
} {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
//TODO: dialog
|
||||
log::warn!("failed to create {:?}: {}", path, err);
|
||||
}
|
||||
}
|
||||
Operation::NewFile { path }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -762,6 +756,7 @@ impl Application for App {
|
|||
}
|
||||
Message::PendingError(id, err) => {
|
||||
if let Some((op, _)) = self.pending_operations.remove(&id) {
|
||||
//TODO: dialog?
|
||||
self.failed_operations.insert(id, (op, err));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue