Expose "report_launch_failure" so engine can call it. (#97)
This commit is contained in:
@@ -21,10 +21,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
|
||||
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.2.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -37,10 +37,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
||||
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.1"
|
||||
version: "1.17.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -94,10 +94,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
||||
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.7"
|
||||
version: "0.6.5"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -110,10 +110,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8
|
||||
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.14"
|
||||
version: "0.12.13"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -126,18 +126,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "12307e7f0605ce3da64cf0db90e5fcab0869f3ca03f76be6bb2991ce0a55e82b"
|
||||
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
version: "1.8.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
version: "1.8.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -187,10 +187,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "6182294da5abf431177fccc1ee02401f6df30f766bc6130a0852c6b6d7ee6b2d"
|
||||
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.18"
|
||||
version: "0.4.16"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -200,4 +200,4 @@ packages:
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
sdks:
|
||||
dart: ">=2.19.0 <4.0.0"
|
||||
dart: ">=2.19.0 <3.0.0"
|
||||
|
||||
@@ -8,7 +8,8 @@ environment:
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
ffi: ^2.0.1
|
||||
path: ^1.8.3
|
||||
# path version must match that depended on by Flutter SDK.
|
||||
path: ^1.8.2
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^2.0.0
|
||||
|
||||
@@ -26,6 +26,7 @@ log = "0.4.14"
|
||||
once_cell = "1.17.1"
|
||||
serde_yaml = "0.9.19"
|
||||
uuid = { version = "1.3.0", features = ["v4", "fast-rng", "macro-diagnostics", "serde"]}
|
||||
sha2 = "0.10.6"
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
android_logger = "0.13.0"
|
||||
@@ -33,4 +34,4 @@ log-panics = { version = "2", features = ["with-backtrace"]}
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
tempdir = "0.3.7"
|
||||
tempdir = "0.3.7"
|
||||
|
||||
@@ -84,6 +84,8 @@ SHOREBIRD_EXPORT bool shorebird_check_for_update(void);
|
||||
*/
|
||||
SHOREBIRD_EXPORT void shorebird_update(void);
|
||||
|
||||
SHOREBIRD_EXPORT void shorebird_report_failed_launch(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -117,3 +117,17 @@ pub extern "C" fn shorebird_check_for_update() -> bool {
|
||||
pub extern "C" fn shorebird_update() {
|
||||
updater::update();
|
||||
}
|
||||
|
||||
/// Report that the app failed to launch. This will cause the updater to
|
||||
/// attempt to roll back to the previous version if this version has not
|
||||
/// been launched successfully before.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn shorebird_report_failed_launch() {
|
||||
let result = updater::report_failed_launch();
|
||||
match result {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
error!("Error recording launch failure: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file deals with the cache / state management for the updater.
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, BufWriter};
|
||||
use std::io::{BufReader, BufWriter, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::Ok;
|
||||
@@ -15,7 +15,7 @@ pub struct PatchInfo {
|
||||
pub number: usize,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Default, Clone)]
|
||||
#[derive(Deserialize, Serialize, Default, Clone, Debug)]
|
||||
struct Slot {
|
||||
/// Path to the slot directory.
|
||||
path: String,
|
||||
@@ -62,6 +62,17 @@ impl UpdaterState {
|
||||
}
|
||||
}
|
||||
|
||||
// fn compute_hash(path: &Path) -> anyhow::Result<String> {
|
||||
// use sha2::{Digest, Sha256};
|
||||
// use std::{fs, io};
|
||||
|
||||
// let mut file = fs::File::open(&path)?;
|
||||
// let mut hasher = Sha256::new();
|
||||
// let n = io::copy(&mut file, &mut hasher)?;
|
||||
// let hash = hasher.finalize();
|
||||
// Ok(format!("{:x}", hash))
|
||||
// }
|
||||
|
||||
impl UpdaterState {
|
||||
pub fn is_known_good_patch(&self, patch: &PatchInfo) -> bool {
|
||||
self.successful_patches.iter().any(|v| v == &patch.number)
|
||||
@@ -80,6 +91,7 @@ impl UpdaterState {
|
||||
if self.is_known_bad_patch(patch) {
|
||||
return;
|
||||
}
|
||||
info!("Marking patch {} as bad", patch.number);
|
||||
self.failed_patches.push(patch.number.clone());
|
||||
}
|
||||
|
||||
@@ -95,7 +107,7 @@ impl UpdaterState {
|
||||
self.successful_patches.push(patch.number.clone());
|
||||
}
|
||||
|
||||
pub fn load(cache_dir: &str) -> anyhow::Result<Self> {
|
||||
fn load(cache_dir: &str) -> anyhow::Result<Self> {
|
||||
// Load UpdaterState from disk
|
||||
let path = Path::new(cache_dir).join("state.json");
|
||||
let file = File::open(path)?;
|
||||
@@ -150,6 +162,13 @@ impl UpdaterState {
|
||||
return true;
|
||||
}
|
||||
// TODO: This should also check if the hash matches?
|
||||
// let hash = compute_hash(&PathBuf::from(&slot.path));
|
||||
// if let Ok(hash) = hash {
|
||||
// if hash == slot.hash {
|
||||
// return true;
|
||||
// }
|
||||
// error!("Hash mismatch for slot: {:?}", slot);
|
||||
// }
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user