mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 12:33:40 +00:00
* refactor project structure * environment-based default registry * fix tests * update build container * use docker platform for iso build emulation * simplify compat * Fix docker platform spec in run-compat.sh * handle riscv compat * fix bug with dep error exists attr * undo removal of sorting * use qemu for iso stage --------- Co-authored-by: Mariusz Kogen <k0gen@pm.me> Co-authored-by: Matt Hill <mattnine@protonmail.com>
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use std::path::Path;
|
|
|
|
use crate::DATA_DIR;
|
|
use crate::service::effects::prelude::*;
|
|
use crate::util::io::{delete_file, maybe_read_file_to_string, write_file_atomic};
|
|
use crate::volume::PKG_VOLUME_DIR;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export)]
|
|
pub struct SetDataVersionParams {
|
|
#[ts(type = "string")]
|
|
version: Option<String>,
|
|
}
|
|
#[instrument(skip(context))]
|
|
pub async fn set_data_version(
|
|
context: EffectContext,
|
|
SetDataVersionParams { version }: SetDataVersionParams,
|
|
) -> Result<(), Error> {
|
|
let context = context.deref()?;
|
|
let package_id = &context.seed.id;
|
|
let path = Path::new(DATA_DIR)
|
|
.join(PKG_VOLUME_DIR)
|
|
.join(package_id)
|
|
.join("data")
|
|
.join(".version");
|
|
if let Some(version) = version {
|
|
write_file_atomic(path, version.as_bytes()).await?;
|
|
} else {
|
|
delete_file(path).await?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[instrument(skip_all)]
|
|
pub async fn get_data_version(context: EffectContext) -> Result<Option<String>, Error> {
|
|
let context = context.deref()?;
|
|
let package_id = &context.seed.id;
|
|
let path = Path::new(DATA_DIR)
|
|
.join(PKG_VOLUME_DIR)
|
|
.join(package_id)
|
|
.join("data")
|
|
.join(".version");
|
|
maybe_read_file_to_string(path).await
|
|
}
|