mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
move manifest to parent
This commit is contained in:
committed by
Aiden McClelland
parent
2e3e551564
commit
e2b77b23f8
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use patch_db::json_ptr::JsonPointer;
|
||||
use patch_db::{HasModel, Map, MapModel, OptionModel};
|
||||
use patch_db::{DbHandle, HasModel, Map, MapModel, OptionModel};
|
||||
use reqwest::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
@@ -12,7 +12,7 @@ use crate::config::spec::{PackagePointerSpecVariant, SystemPointerSpec};
|
||||
use crate::install::progress::InstallProgress;
|
||||
use crate::net::interface::InterfaceId;
|
||||
use crate::net::Network;
|
||||
use crate::s9pk::manifest::{Manifest, PackageId};
|
||||
use crate::s9pk::manifest::{Manifest, ManifestModel, PackageId};
|
||||
use crate::status::health_check::HealthCheckId;
|
||||
use crate::status::Status;
|
||||
use crate::util::Version;
|
||||
@@ -115,24 +115,25 @@ pub enum PackageDataEntry {
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
Installing {
|
||||
static_files: StaticFiles,
|
||||
temp_manifest: Manifest,
|
||||
manifest: Manifest,
|
||||
install_progress: Arc<InstallProgress>,
|
||||
}, // { state: "installing", 'install-progress': InstallProgress }
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
Updating {
|
||||
static_files: StaticFiles,
|
||||
temp_manifest: Manifest,
|
||||
manifest: Manifest,
|
||||
installed: InstalledPackageDataEntry,
|
||||
install_progress: Arc<InstallProgress>,
|
||||
},
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
Removing {
|
||||
static_files: StaticFiles,
|
||||
temp_manifest: Manifest,
|
||||
manifest: Manifest,
|
||||
},
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
Installed {
|
||||
static_files: StaticFiles,
|
||||
manifest: Manifest,
|
||||
installed: InstalledPackageDataEntry,
|
||||
},
|
||||
}
|
||||
@@ -143,13 +144,14 @@ impl PackageDataEntryModel {
|
||||
pub fn install_progress(self) -> OptionModel<InstallProgress> {
|
||||
self.0.child("install-progress").into()
|
||||
}
|
||||
pub fn manifest(self) -> ManifestModel {
|
||||
self.0.child("manifest").into()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, HasModel)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct InstalledPackageDataEntry {
|
||||
#[model]
|
||||
pub manifest: Manifest,
|
||||
#[model]
|
||||
pub status: Status,
|
||||
pub system_pointers: Vec<SystemPointerSpec>,
|
||||
@@ -160,6 +162,13 @@ pub struct InstalledPackageDataEntry {
|
||||
#[model]
|
||||
pub interface_info: InterfaceInfo,
|
||||
}
|
||||
impl InstalledPackageDataEntryModel {
|
||||
pub fn manifest(self) -> ManifestModel {
|
||||
let mut ptr = JsonPointer::from(self);
|
||||
ptr.pop_end();
|
||||
PackageDataEntryModel::from(ptr).manifest()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
|
||||
@@ -89,19 +89,23 @@ pub async fn download_install_s9pk(
|
||||
let static_files = StaticFiles::remote(pkg_id, version, temp_manifest.assets.icon_type());
|
||||
let mut pde = pkg_data_entry.get_mut(&mut db).await?;
|
||||
match pde.take() {
|
||||
Some(PackageDataEntry::Installed { installed, .. }) => {
|
||||
Some(PackageDataEntry::Installed {
|
||||
installed,
|
||||
manifest,
|
||||
static_files,
|
||||
}) => {
|
||||
*pde = Some(PackageDataEntry::Updating {
|
||||
install_progress: progress.clone(),
|
||||
static_files,
|
||||
installed,
|
||||
temp_manifest: temp_manifest.clone(),
|
||||
manifest,
|
||||
})
|
||||
}
|
||||
None => {
|
||||
*pde = Some(PackageDataEntry::Installing {
|
||||
install_progress: progress.clone(),
|
||||
static_files,
|
||||
temp_manifest: temp_manifest.clone(),
|
||||
manifest: temp_manifest.clone(),
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
@@ -393,7 +397,6 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
})
|
||||
.collect();
|
||||
let installed = InstalledPackageDataEntry {
|
||||
manifest: manifest.clone(),
|
||||
status: Status {
|
||||
configured: manifest.config.is_none(),
|
||||
main: MainStatus::Stopped,
|
||||
@@ -433,23 +436,25 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
&mut *pde,
|
||||
PackageDataEntry::Installed {
|
||||
installed,
|
||||
manifest: manifest.clone(),
|
||||
static_files,
|
||||
},
|
||||
);
|
||||
pde.save(&mut tx).await?;
|
||||
if let PackageDataEntry::Updating {
|
||||
installed: prev, ..
|
||||
installed: prev,
|
||||
manifest: prev_manifest,
|
||||
..
|
||||
} = prev
|
||||
{
|
||||
let mut configured = prev.status.configured;
|
||||
if let Some(res) = prev
|
||||
.manifest
|
||||
if let Some(res) = prev_manifest
|
||||
.migrations
|
||||
.to(
|
||||
version,
|
||||
pkg_id,
|
||||
&prev.manifest.version,
|
||||
&prev.manifest.volumes,
|
||||
&prev_manifest.version,
|
||||
&prev_manifest.volumes,
|
||||
&hosts,
|
||||
)
|
||||
.await?
|
||||
@@ -460,7 +465,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
if let Some(res) = manifest
|
||||
.migrations
|
||||
.from(
|
||||
&prev.manifest.version,
|
||||
&prev_manifest.version,
|
||||
pkg_id,
|
||||
version,
|
||||
&manifest.volumes,
|
||||
|
||||
Reference in New Issue
Block a user