allow fs scope on file drop

pull/355/head
Lucas Nogueira 2 years ago
parent 64cb3c7490
commit 7e85e09ab9
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -5,7 +5,7 @@
use config::FsScope;
use tauri::{
plugin::{Builder as PluginBuilder, TauriPlugin},
Manager, Runtime,
FileDropEvent, Manager, RunEvent, Runtime, WindowEvent,
};
mod commands;
@ -60,5 +60,22 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
));
Ok(())
})
.on_event(|app, event| {
if let RunEvent::WindowEvent {
label: _,
event: WindowEvent::FileDrop(FileDropEvent::Dropped(paths)),
..
} = event
{
let scope = app.fs_scope();
for path in paths {
if path.is_file() {
let _ = scope.allow_file(path);
} else {
let _ = scope.allow_directory(path, false);
}
}
}
})
.build()
}

Loading…
Cancel
Save