diff --git a/backend/src/backup/backup_bulk.rs b/backend/src/backup/backup_bulk.rs index 8331c9d64..bc9ca8237 100644 --- a/backend/src/backup/backup_bulk.rs +++ b/backend/src/backup/backup_bulk.rs @@ -366,6 +366,7 @@ async fn perform_backup( .backup .create( ctx, + &mut tx, &package_id, &manifest.title, &manifest.version, diff --git a/backend/src/backup/mod.rs b/backend/src/backup/mod.rs index b8f055596..3cc3f5bd8 100644 --- a/backend/src/backup/mod.rs +++ b/backend/src/backup/mod.rs @@ -5,6 +5,7 @@ use chrono::{DateTime, Utc}; use color_eyre::eyre::eyre; use helpers::AtomicFile; use patch_db::{DbHandle, HasModel, LockType}; +use reqwest::Url; use rpc_toolkit::command; use serde::{Deserialize, Serialize}; use sqlx::{Executor, Sqlite}; @@ -61,6 +62,7 @@ pub fn package_backup() -> Result<(), Error> { struct BackupMetadata { pub timestamp: DateTime, pub tor_keys: BTreeMap, + pub marketplace_url: Option, } #[derive(Clone, Debug, Deserialize, Serialize, HasModel)] @@ -84,10 +86,11 @@ impl BackupActions { Ok(()) } - #[instrument(skip(ctx))] - pub async fn create( + #[instrument(skip(ctx, db))] + pub async fn create( &self, ctx: &RpcContext, + db: &mut Db, pkg_id: &PackageId, pkg_title: &str, pkg_version: &Version, @@ -125,6 +128,18 @@ impl BackupActions { ) }) .collect(); + let marketplace_url = crate::db::DatabaseModel::new() + .package_data() + .idx_model(pkg_id) + .expect(db) + .await? + .installed() + .expect(db) + .await? + .marketplace_url() + .get(db, true) + .await? + .into_owned(); let tmp_path = Path::new(BACKUP_DIR) .join(pkg_id) .join(format!("{}.s9pk", pkg_id)); @@ -156,6 +171,7 @@ impl BackupActions { .write_all(&IoFormat::Cbor.to_vec(&BackupMetadata { timestamp, tor_keys, + marketplace_url, })?) .await?; outfile.save().await.with_kind(ErrorKind::Filesystem)?; @@ -227,17 +243,21 @@ impl BackupActions { .package_data() .lock(db, LockType::Write) .await?; - crate::db::DatabaseModel::new() + let pde = crate::db::DatabaseModel::new() .package_data() .idx_model(pkg_id) .expect(db) .await? .installed() .expect(db) - .await? + .await?; + pde.clone() .interface_addresses() .put(db, &interfaces.install(&mut *secrets, pkg_id).await?) .await?; + pde.marketplace_url() + .put(db, &metadata.marketplace_url) + .await?; let entry = crate::db::DatabaseModel::new() .package_data()