[ENG-694] Remove Spacedrop (#914)

* goodbye Spacedrop

* fix startup error escaping

* fix error fallback being cringe with long error

* backwards compatibility for early adopters
This commit is contained in:
Oscar Beaumont 2023-06-06 18:56:31 +08:00 committed by GitHub
parent a3a4efbc59
commit 41933c8b80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 16 deletions

View file

@ -9,16 +9,7 @@ repository.workspace = true
edition.workspace = true
[dependencies]
tauri = { version = "1.3.0", features = [
"dialog-all",
"linux-protocol-headers",
"macos-private-api",
"os-all",
"path-all",
"protocol-all",
"shell-all",
"window-all",
] }
tauri = { version = "1.3.0", features = ["dialog-all", "linux-protocol-headers", "macos-private-api", "os-all", "path-all", "protocol-all", "shell-all", "window-all"] }
rspc = { workspace = true, features = ["tauri"] }
httpz = { workspace = true, features = [
"axum",

View file

@ -52,7 +52,7 @@ async fn open_logs_dir(node: tauri::State<'_, Arc<Node>>) -> Result<(), ()> {
pub fn tauri_error_plugin<R: Runtime>(err: NodeError) -> TauriPlugin<R> {
tauri::plugin::Builder::new("spacedrive")
.js_init_script(format!(r#"window.__SD_ERROR__ = "{err}";"#))
.js_init_script(format!(r#"window.__SD_ERROR__ = `{err}`;"#))
.build()
}

View file

@ -106,7 +106,8 @@ impl P2PManager {
.ok();
// TODO: Don't just connect to everyone when we find them. We should only do it if we know them.
event.dial().await;
// TODO(Spacedrop): Disable Spacedrop for now
// event.dial().await;
}
Event::PeerMessage(mut event) => {
let events = events.clone();

View file

@ -52,7 +52,33 @@ where
match path.try_exists()? {
true => {
let mut file = File::options().read(true).write(true).open(path)?;
let mut cfg: BaseConfig = serde_json::from_reader(BufReader::new(&mut file))?;
let mut cfg: BaseConfig = match serde_json::from_reader(BufReader::new(&mut file)) {
Ok(cfg) => cfg,
Err(err) => {
// This is for backwards compatibility for the backwards compatibility cause the super super old system store the version as a string.
{
file.rewind()?;
let mut y = match serde_json::from_reader::<_, Value>(BufReader::new(
&mut file,
)) {
Ok(y) => y,
Err(_) => {
return Err(err.into());
}
};
if let Some(obj) = y.as_object_mut() {
if let Some(_) = obj.get("version").and_then(|v| v.as_str()) {
return Err(MigratorError::HasSuperLegacyConfig); // This is just to make the error nicer
} else {
return Err(err.into());
}
} else {
return Err(err.into());
}
}
}
};
file.rewind()?; // Fail early so we don't end up invalid state
if cfg.version > self.current_version {
@ -112,6 +138,8 @@ pub enum MigratorError {
YourAppIsOutdated,
#[error("Type '{0}' as generic `Migrator::T` must be serialiable to a Serde object!")]
InvalidType(&'static str),
#[error("We detected a Spacedrive config from a super early version of the app!")]
HasSuperLegacyConfig,
#[error("custom migration error: {0}")]
Custom(String),
}

View file

@ -32,6 +32,13 @@ export default ({ error, resetErrorBoundary }: FallbackProps) => (
/>
);
// This is sketchy but these are all edge cases that will only be encountered by developers if everything works as expected so it's probs fine
const errorsThatRequireACoreReset = [
'failed to initialize config',
'failed to initialize library manager: failed to run library migrations',
'failed to initialize config: We detected a Spacedrive config from a super early version of the app!'
];
export function ErrorPage({
reloadBtn,
sendReportBtn,
@ -61,7 +68,9 @@ export function ErrorPage({
>
<p className="m-3 text-sm font-bold text-ink-faint">APP CRASHED</p>
<h1 className="text-2xl font-bold text-ink">We're past the event horizon...</h1>
<pre className="m-2 text-ink">{message}</pre>
<pre className="m-2 max-w-[650px] whitespace-normal text-center text-ink">
{message}
</pre>
{submessage && <pre className="m-2 text-sm text-ink-dull">{submessage}</pre>}
<div className="flex flex-row space-x-2 text-ink">
{reloadBtn && (
@ -74,7 +83,7 @@ export function ErrorPage({
Send report
</Button>
)}
{message === 'failed to initialize config' && (
{errorsThatRequireACoreReset.includes(message) && (
<div className="flex flex-col items-center pt-12">
<p className="text-md max-w-[650px] text-center">
We detected you may have created your library with an older version of
@ -92,7 +101,7 @@ export function ErrorPage({
window.__TAURI_INVOKE__('reset_spacedrive');
}}
>
Reset Library
Reset Spacedrive
</Button>
</div>
)}

View file

@ -14,6 +14,9 @@ import { getSpacedropState, subscribeSpacedropState } from '../hooks/useSpacedro
const { Input, useZodForm, z } = forms;
export function SpacedropUI() {
// TODO(Spacedrop): Disable Spacedrop for now
return null;
useEffect(() =>
subscribeSpacedropState(() => {
dialogManager.create((dp) => <SpacedropDialog {...dp} />);