mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
adds package list functionality
This commit is contained in:
committed by
Aiden McClelland
parent
678fa0731e
commit
78dcce7be5
@@ -6,6 +6,20 @@ use std::process::Stdio;
|
|||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use color_eyre::eyre::{self, eyre};
|
||||||
|
use emver::VersionRange;
|
||||||
|
use futures::future::BoxFuture;
|
||||||
|
use futures::{FutureExt, StreamExt, TryStreamExt};
|
||||||
|
use http::StatusCode;
|
||||||
|
use patch_db::{DbHandle, LockType};
|
||||||
|
use reqwest::Response;
|
||||||
|
use rpc_toolkit::command;
|
||||||
|
use tokio::fs::{DirEntry, File, OpenOptions};
|
||||||
|
use tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt};
|
||||||
|
use tokio::process::Command;
|
||||||
|
use tokio_stream::wrappers::ReadDirStream;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
use self::cleanup::cleanup_failed;
|
use self::cleanup::cleanup_failed;
|
||||||
use crate::context::RpcContext;
|
use crate::context::RpcContext;
|
||||||
use crate::db::model::{
|
use crate::db::model::{
|
||||||
@@ -26,19 +40,6 @@ use crate::util::io::copy_and_shutdown;
|
|||||||
use crate::util::{display_none, display_serializable, AsyncFileExt, Version};
|
use crate::util::{display_none, display_serializable, AsyncFileExt, Version};
|
||||||
use crate::volume::asset_dir;
|
use crate::volume::asset_dir;
|
||||||
use crate::{Error, ResultExt};
|
use crate::{Error, ResultExt};
|
||||||
use color_eyre::eyre::{self, eyre};
|
|
||||||
use emver::VersionRange;
|
|
||||||
use futures::future::BoxFuture;
|
|
||||||
use futures::{FutureExt, StreamExt, TryStreamExt};
|
|
||||||
use http::StatusCode;
|
|
||||||
use patch_db::{DbHandle, LockType};
|
|
||||||
use reqwest::Response;
|
|
||||||
use rpc_toolkit::command;
|
|
||||||
use tokio::fs::{DirEntry, File, OpenOptions};
|
|
||||||
use tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt};
|
|
||||||
use tokio::process::Command;
|
|
||||||
use tokio_stream::wrappers::ReadDirStream;
|
|
||||||
use tracing::instrument;
|
|
||||||
|
|
||||||
pub mod cleanup;
|
pub mod cleanup;
|
||||||
pub mod progress;
|
pub mod progress;
|
||||||
@@ -48,6 +49,26 @@ pub const PKG_PUBLIC_DIR: &'static str = "package-data/public";
|
|||||||
pub const PKG_DOCKER_DIR: &'static str = "package-data/docker";
|
pub const PKG_DOCKER_DIR: &'static str = "package-data/docker";
|
||||||
pub const PKG_WASM_DIR: &'static str = "package-data/wasm";
|
pub const PKG_WASM_DIR: &'static str = "package-data/wasm";
|
||||||
|
|
||||||
|
#[command(display(display_serializable))]
|
||||||
|
pub async fn list(#[context] ctx: RpcContext) -> Result<Vec<(PackageId, Version)>, Error> {
|
||||||
|
let mut hdl = ctx.db.handle();
|
||||||
|
let package_data = crate::db::DatabaseModel::new()
|
||||||
|
.package_data()
|
||||||
|
.get(&mut hdl, true)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(package_data
|
||||||
|
.0
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(id, pde)| match pde {
|
||||||
|
PackageDataEntry::Installed { installed, .. } => {
|
||||||
|
Some((id.clone(), installed.manifest.version.clone()))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
#[command(display(display_none))]
|
#[command(display(display_none))]
|
||||||
#[instrument(skip(ctx))]
|
#[instrument(skip(ctx))]
|
||||||
pub async fn install(
|
pub async fn install(
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ pub fn server() -> Result<(), RpcError> {
|
|||||||
action::action,
|
action::action,
|
||||||
install::install,
|
install::install,
|
||||||
install::uninstall,
|
install::uninstall,
|
||||||
|
install::list,
|
||||||
config::config,
|
config::config,
|
||||||
control::start,
|
control::start,
|
||||||
control::stop,
|
control::stop,
|
||||||
|
|||||||
Reference in New Issue
Block a user