Skip to content

Commit fa99208

Browse files
committed
refactor(db): drop with_pkg_id
1 parent 1b45180 commit fa99208

12 files changed

Lines changed: 6 additions & 52 deletions

File tree

crates/soar-cli/src/apply.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ fn create_install_target(
389389
InstallTarget {
390390
package,
391391
existing_install: existing,
392-
with_pkg_id: false,
393392
pinned: resolved.pinned,
394393
profile: resolved.profile.clone(),
395394
portable: resolved.portable.as_ref().and_then(|p| p.path.clone()),
@@ -416,7 +415,6 @@ fn create_url_install_target(
416415
InstallTarget {
417416
package: url_pkg.to_package(),
418417
existing_install: existing,
419-
with_pkg_id: false,
420418
pinned: resolved.pinned,
421419
profile: resolved.profile.clone(),
422420
portable: resolved.portable.as_ref().and_then(|p| p.path.clone()),

crates/soar-cli/src/install.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ fn resolve_packages(
269269
install_targets.push(InstallTarget {
270270
package: url_pkg.to_package(),
271271
existing_install,
272-
with_pkg_id: false,
273272
pinned: false,
274273
profile: None,
275274
..Default::default()
@@ -396,7 +395,6 @@ fn resolve_packages(
396395
install_targets.push(InstallTarget {
397396
package: pkg,
398397
existing_install,
399-
with_pkg_id: false,
400398
pinned: query.version.is_some(),
401399
profile: None,
402400
..Default::default()
@@ -573,7 +571,6 @@ fn resolve_packages(
573571
install_targets.push(InstallTarget {
574572
package: pkg,
575573
existing_install,
576-
with_pkg_id: true,
577574
pinned: query.version.is_some(),
578575
profile: None,
579576
..Default::default()
@@ -649,9 +646,6 @@ fn resolve_packages(
649646
.find(|ip| ip.pkg_name == pkg.pkg_name)
650647
.cloned();
651648
if let Some(ref existing) = existing_install {
652-
if !existing.with_pkg_id {
653-
continue;
654-
}
655649
if existing.is_installed {
656650
warn!(
657651
"{}#{}:{} ({}) is already installed - {}",
@@ -670,7 +664,6 @@ fn resolve_packages(
670664
install_targets.push(InstallTarget {
671665
package: pkg,
672666
existing_install,
673-
with_pkg_id: true,
674667
pinned: query.version.is_some(),
675668
profile: None,
676669
..Default::default()
@@ -711,7 +704,6 @@ fn resolve_packages(
711704
install_targets.push(InstallTarget {
712705
package: db_pkg,
713706
existing_install,
714-
with_pkg_id: false,
715707
pinned: query.version.is_some(),
716708
profile: None,
717709
..Default::default()
@@ -1158,7 +1150,6 @@ pub async fn install_single_package(
11581150
&install_dir,
11591151
Some(progress_callback),
11601152
core_db,
1161-
target.with_pkg_id,
11621153
install_patterns.to_vec(),
11631154
)
11641155
.await?;

crates/soar-cli/src/remove.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ pub async fn remove_packages(packages: &[String], yes: bool, all: bool) -> SoarR
213213
}
214214
} else {
215215
installed_pkgs
216-
.into_iter()
217-
.filter(|pkg| query.name.is_some() || pkg.with_pkg_id)
218-
.collect()
219216
};
220217

221218
debug!(count = pkgs_to_remove.len(), "packages to remove");

crates/soar-cli/src/update.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ pub async fn update_packages(
133133
});
134134

135135
if let Some(package) = new_pkg {
136-
let with_pkg_id = pkg.with_pkg_id;
137-
138136
// Check if the new version is already installed (skip if so)
139137
let new_version_installed = get_existing(&package, &diesel_db)?;
140138
if let Some(ref installed) = new_version_installed {
@@ -146,7 +144,6 @@ pub async fn update_packages(
146144
update_targets.push(InstallTarget {
147145
package,
148146
existing_install: Some(pkg.clone()),
149-
with_pkg_id,
150147
pinned: pkg.pinned,
151148
profile: Some(pkg.profile.clone()),
152149
portable: pkg.portable_path.clone(),
@@ -223,8 +220,6 @@ pub async fn update_packages(
223220
});
224221

225222
if let Some(package) = new_pkg {
226-
let with_pkg_id = pkg.with_pkg_id;
227-
228223
// Check if the new version is already installed (skip if so)
229224
let new_version_installed = get_existing(&package, &diesel_db)?;
230225
if let Some(ref installed) = new_version_installed {
@@ -238,7 +233,6 @@ pub async fn update_packages(
238233
update_targets.push(InstallTarget {
239234
package,
240235
existing_install: Some(pkg.clone()),
241-
with_pkg_id,
242236
pinned: pkg.pinned,
243237
profile: Some(pkg.profile.clone()),
244238
portable: pkg.portable_path.clone(),
@@ -389,7 +383,6 @@ fn check_local_package_update(
389383
let target = InstallTarget {
390384
package: updated_url_pkg.to_package(),
391385
existing_install: Some(pkg.clone()),
392-
with_pkg_id: pkg.with_pkg_id,
393386
pinned: resolved.pinned,
394387
profile: resolved.profile.clone(),
395388
portable: resolved.portable.as_ref().and_then(|p| p.path.clone()),

crates/soar-core/src/database/models.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ pub struct InstalledPackage {
102102
pub profile: String,
103103
pub pinned: bool,
104104
pub is_installed: bool,
105-
pub with_pkg_id: bool,
106105
pub detached: bool,
107106
pub unlinked: bool,
108107
pub provides: Option<Vec<PackageProvide>>,
@@ -149,7 +148,6 @@ impl From<InstalledPackageWithPortable> for InstalledPackage {
149148
profile: pkg.profile,
150149
pinned: pkg.pinned,
151150
is_installed: pkg.is_installed,
152-
with_pkg_id: pkg.with_pkg_id,
153151
detached: pkg.detached,
154152
unlinked: pkg.unlinked,
155153
provides: pkg.provides,
@@ -180,7 +178,6 @@ impl From<soar_db::repository::core::InstalledPackage> for InstalledPackage {
180178
profile: pkg.profile,
181179
pinned: pkg.pinned,
182180
is_installed: pkg.is_installed,
183-
with_pkg_id: pkg.with_pkg_id,
184181
detached: pkg.detached,
185182
unlinked: pkg.unlinked,
186183
provides: pkg.provides,

crates/soar-core/src/package/install.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ pub struct PackageInstaller {
118118
install_dir: PathBuf,
119119
progress_callback: Option<std::sync::Arc<dyn Fn(Progress) + Send + Sync>>,
120120
db: DieselDatabase,
121-
with_pkg_id: bool,
122121
globs: Vec<String>,
123122
nested_extract: Option<String>,
124123
extract_root: Option<String>,
@@ -131,7 +130,6 @@ pub struct PackageInstaller {
131130
pub struct InstallTarget {
132131
pub package: Package,
133132
pub existing_install: Option<crate::database::models::InstalledPackage>,
134-
pub with_pkg_id: bool,
135133
pub pinned: bool,
136134
pub profile: Option<String>,
137135
pub portable: Option<String>,
@@ -154,7 +152,6 @@ impl PackageInstaller {
154152
install_dir: P,
155153
progress_callback: Option<std::sync::Arc<dyn Fn(Progress) + Send + Sync>>,
156154
db: DieselDatabase,
157-
with_pkg_id: bool,
158155
globs: Vec<String>,
159156
) -> SoarResult<Self> {
160157
let install_dir = install_dir.as_ref().to_path_buf();
@@ -243,7 +240,6 @@ impl PackageInstaller {
243240
profile: &profile,
244241
pinned: target.pinned,
245242
is_installed: false,
246-
with_pkg_id,
247243
detached: false,
248244
unlinked: false,
249245
provides: None,
@@ -258,7 +254,6 @@ impl PackageInstaller {
258254
install_dir,
259255
progress_callback,
260256
db,
261-
with_pkg_id,
262257
globs,
263258
nested_extract: target.nested_extract.clone(),
264259
extract_root: target.extract_root.clone(),
@@ -743,7 +738,6 @@ impl PackageInstaller {
743738
let checksum = package.bsum.as_deref();
744739
let provides = package.provides.clone();
745740

746-
let with_pkg_id = self.with_pkg_id;
747741
let installed_date = Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();
748742

749743
let installed_path = self.install_dir.to_string_lossy();
@@ -756,7 +750,6 @@ impl PackageInstaller {
756750
version,
757751
size,
758752
provides,
759-
with_pkg_id,
760753
checksum,
761754
&installed_date,
762755
&installed_path,

crates/soar-core/src/package/url.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,6 @@ mod tests {
407407
assert_eq!(pkg.pkg_id, "example.com.downloads.app");
408408
}
409409

410-
#[test]
411-
fn test_parse_with_pkg_id_override() {
412-
let url = "https://example.com/app.AppImage";
413-
let pkg = UrlPackage::from_url(url, None, None, None, Some("custom-id")).unwrap();
414-
415-
assert_eq!(pkg.pkg_id, "custom-id");
416-
}
417-
418410
#[test]
419411
fn test_extract_pkg_id_from_url() {
420412
assert_eq!(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages ADD COLUMN with_pkg_id BOOLEAN NOT NULL DEFAULT false;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages DROP COLUMN with_pkg_id;

crates/soar-db/src/models/core.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub struct Package {
1818
pub profile: String,
1919
pub pinned: bool,
2020
pub is_installed: bool,
21-
pub with_pkg_id: bool,
2221
pub detached: bool,
2322
pub unlinked: bool,
2423
pub provides: Option<Vec<PackageProvide>>,
@@ -42,7 +41,6 @@ impl Queryable<packages::SqlType, Sqlite> for Package {
4241
bool,
4342
bool,
4443
bool,
45-
bool,
4644
Option<Value>,
4745
Option<Value>,
4846
);
@@ -62,11 +60,10 @@ impl Queryable<packages::SqlType, Sqlite> for Package {
6260
profile: row.10,
6361
pinned: row.11,
6462
is_installed: row.12,
65-
with_pkg_id: row.13,
66-
detached: row.14,
67-
unlinked: row.15,
68-
provides: json_vec!(row.16),
69-
install_patterns: json_vec!(row.17),
63+
detached: row.13,
64+
unlinked: row.14,
65+
provides: json_vec!(row.15),
66+
install_patterns: json_vec!(row.16),
7067
})
7168
}
7269
}
@@ -98,7 +95,6 @@ pub struct NewPackage<'a> {
9895
pub profile: &'a str,
9996
pub pinned: bool,
10097
pub is_installed: bool,
101-
pub with_pkg_id: bool,
10298
pub detached: bool,
10399
pub unlinked: bool,
104100
pub provides: Option<Value>,

0 commit comments

Comments
 (0)