mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
Bugfix/0.3.3 migration (#1922)
* feat: Change migration to use empty name * chore: Add in the default routes just in case * Fix/remove merge with seed during init (#1917) * fix kiosk * chore: Remove the duplicate loggging information that is making usele… (#1912) chore: Remove the duplicate loggging information that is making useless noise in the system. * fix: Remove the init merge with seed Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: BluJ <mogulslayer@gmail.com> Co-authored-by: J M <2364004+Blu-J@users.noreply.github.com>
This commit is contained in:
@@ -203,24 +203,6 @@ pub async fn init(cfg: &RpcContextConfig) -> Result<InitResult, Error> {
|
|||||||
.lock(&mut handle, LockType::Write)
|
.lock(&mut handle, LockType::Write)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let defaults: serde_json::Value =
|
|
||||||
serde_json::from_str(include_str!("../../frontend/patchdb-ui-seed.json")).map_err(|x| {
|
|
||||||
Error::new(
|
|
||||||
eyre!("Deserialization error {:?}", x),
|
|
||||||
crate::ErrorKind::Deserialization,
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
let mut ui = crate::db::DatabaseModel::new()
|
|
||||||
.ui()
|
|
||||||
.get(&mut handle, false)
|
|
||||||
.await?
|
|
||||||
.clone();
|
|
||||||
ui.merge_with(&defaults);
|
|
||||||
crate::db::DatabaseModel::new()
|
|
||||||
.ui()
|
|
||||||
.put(&mut handle, &ui)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let receipts = InitReceipts::new(&mut handle).await?;
|
let receipts = InitReceipts::new(&mut handle).await?;
|
||||||
|
|
||||||
let should_rebuild = tokio::fs::metadata(SYSTEM_REBUILD_PATH).await.is_ok()
|
let should_rebuild = tokio::fs::metadata(SYSTEM_REBUILD_PATH).await.is_ok()
|
||||||
|
|||||||
@@ -2,10 +2,34 @@ use emver::VersionRange;
|
|||||||
|
|
||||||
use super::v0_3_0::V0_3_0_COMPAT;
|
use super::v0_3_0::V0_3_0_COMPAT;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::hostname::{generate_id, sync_hostname};
|
use crate::{
|
||||||
|
config::util::MergeWith,
|
||||||
|
hostname::{generate_id, sync_hostname},
|
||||||
|
};
|
||||||
|
|
||||||
const V0_3_2: emver::Version = emver::Version::new(0, 3, 2, 0);
|
const V0_3_2: emver::Version = emver::Version::new(0, 3, 2, 0);
|
||||||
|
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
static ref DEFAULT_UI: serde_json::Value =serde_json::json!({
|
||||||
|
"name": null,
|
||||||
|
"auto-check-updates": true,
|
||||||
|
"pkg-order": [],
|
||||||
|
"ack-welcome": "0.3.2",
|
||||||
|
"marketplace": {
|
||||||
|
"selected-id": null,
|
||||||
|
"known-hosts": {}
|
||||||
|
},
|
||||||
|
"dev": {},
|
||||||
|
"gaming": {
|
||||||
|
"snake": {
|
||||||
|
"high-score": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ack-instructions": {}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Version;
|
pub struct Version;
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -25,6 +49,14 @@ impl VersionT for Version {
|
|||||||
crate::hostname::ensure_hostname_is_set(db, &receipts).await?;
|
crate::hostname::ensure_hostname_is_set(db, &receipts).await?;
|
||||||
receipts.id.set(db, generate_id()).await?;
|
receipts.id.set(db, generate_id()).await?;
|
||||||
|
|
||||||
|
let mut ui = crate::db::DatabaseModel::new()
|
||||||
|
.ui()
|
||||||
|
.get(db, false)
|
||||||
|
.await?
|
||||||
|
.clone();
|
||||||
|
ui.merge_with(&DEFAULT_UI);
|
||||||
|
crate::db::DatabaseModel::new().ui().put(db, &ui).await?;
|
||||||
|
|
||||||
sync_hostname(db, &receipts).await?;
|
sync_hostname(db, &receipts).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,13 +58,18 @@ impl VersionT for Version {
|
|||||||
obj.remove("auto-check-updates");
|
obj.remove("auto-check-updates");
|
||||||
}
|
}
|
||||||
let known_hosts = ui["marketplace"]["known-hosts"].take();
|
let known_hosts = ui["marketplace"]["known-hosts"].take();
|
||||||
|
ui["marketplace"]["known-hosts"] = json!({});
|
||||||
if let Value::Object(known_hosts) = known_hosts {
|
if let Value::Object(known_hosts) = known_hosts {
|
||||||
for (_id, value) in known_hosts {
|
for (_id, value) in known_hosts {
|
||||||
if let (Value::String(name), Value::String(url)) = (&value["name"], &value["url"]) {
|
if let Value::String(url) = &value["url"] {
|
||||||
ui["marketplace"]["known-hosts"][name] = json!(url);
|
ui["marketplace"]["known-hosts"][url] = json!({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui["marketplace"]["known-hosts"]["https://registry.start9.com/"] = json!({});
|
||||||
|
ui["marketplace"]["known-hosts"]["https://community-registry.start9.com/"] = json!({});
|
||||||
|
|
||||||
if let Some(Value::Object(ref mut obj)) = ui.get_mut("marketplace") {
|
if let Some(Value::Object(ref mut obj)) = ui.get_mut("marketplace") {
|
||||||
obj.remove("selected-id");
|
obj.remove("selected-id");
|
||||||
}
|
}
|
||||||
@@ -105,10 +110,10 @@ impl VersionT for Version {
|
|||||||
let known_hosts = ui["marketplace"]["known-hosts"].take();
|
let known_hosts = ui["marketplace"]["known-hosts"].take();
|
||||||
ui["marketplace"]["known-hosts"] = json!({});
|
ui["marketplace"]["known-hosts"] = json!({});
|
||||||
if let Value::Object(known_hosts) = known_hosts {
|
if let Value::Object(known_hosts) = known_hosts {
|
||||||
for (url, name) in known_hosts {
|
for (url, obj) in known_hosts {
|
||||||
if let Value::String(name) = name {
|
if let Value::String(name) = &obj["name"] {
|
||||||
let id = uuid::Uuid::new_v4().to_string();
|
let id = uuid::Uuid::new_v4().to_string();
|
||||||
if Some(&name) == selected_url.as_ref() {
|
if Some(name) == selected_url.as_ref() {
|
||||||
ui["marketplace"]["selected-id"] = Value::String(id.clone());
|
ui["marketplace"]["selected-id"] = Value::String(id.clone());
|
||||||
}
|
}
|
||||||
ui["marketplace"]["known-hosts"][id.as_str()] = json!({
|
ui["marketplace"]["known-hosts"][id.as_str()] = json!({
|
||||||
|
|||||||
Reference in New Issue
Block a user