Fix performance, add screenshots, make banner scrollable

This commit is contained in:
2026-02-27 18:44:50 +02:00
parent 87f4e5d7bf
commit a755e546d0
8 changed files with 231 additions and 34 deletions

View File

@@ -63,6 +63,7 @@ pub struct AppImageRecord {
pub release_history: Option<String>,
pub desktop_actions: Option<String>,
pub has_signature: bool,
pub screenshot_urls: Option<String>,
}
#[derive(Debug, Clone)]
@@ -360,6 +361,10 @@ impl Database {
self.migrate_to_v9()?;
}
if current_version < 10 {
self.migrate_to_v10()?;
}
// Ensure all expected columns exist (repairs DBs where a migration
// was updated after it had already run on this database)
self.ensure_columns()?;
@@ -736,6 +741,30 @@ impl Database {
Ok(())
}
fn migrate_to_v10(&self) -> SqlResult<()> {
let sql = "ALTER TABLE appimages ADD COLUMN screenshot_urls TEXT";
match self.conn.execute(sql, []) {
Ok(_) => {}
Err(e) => {
let msg = e.to_string();
if !msg.contains("duplicate column") {
return Err(e);
}
}
}
// Force one-time re-analysis so the new AppStream parser (screenshots,
// extended metadata) runs on existing apps
self.conn.execute(
"UPDATE appimages SET analysis_status = NULL WHERE analysis_status = 'complete'",
[],
)?;
self.conn.execute(
"UPDATE schema_version SET version = ?1",
params![10],
)?;
Ok(())
}
pub fn upsert_appimage(
&self,
path: &str,
@@ -820,6 +849,7 @@ impl Database {
release_history: Option<&str>,
desktop_actions: Option<&str>,
has_signature: bool,
screenshot_urls: Option<&str>,
) -> SqlResult<()> {
self.conn.execute(
"UPDATE appimages SET
@@ -838,7 +868,8 @@ impl Database {
project_group = ?14,
release_history = ?15,
desktop_actions = ?16,
has_signature = ?17
has_signature = ?17,
screenshot_urls = ?18
WHERE id = ?1",
params![
id,
@@ -858,6 +889,7 @@ impl Database {
release_history,
desktop_actions,
has_signature,
screenshot_urls,
],
)?;
Ok(())
@@ -902,7 +934,7 @@ impl Database {
appstream_id, appstream_description, generic_name, license,
homepage_url, bugtracker_url, donation_url, help_url, vcs_url,
keywords, mime_types, content_rating, project_group,
release_history, desktop_actions, has_signature";
release_history, desktop_actions, has_signature, screenshot_urls";
fn row_to_record(row: &rusqlite::Row) -> rusqlite::Result<AppImageRecord> {
Ok(AppImageRecord {
@@ -959,6 +991,7 @@ impl Database {
release_history: row.get(50).unwrap_or(None),
desktop_actions: row.get(51).unwrap_or(None),
has_signature: row.get::<_, bool>(52).unwrap_or(false),
screenshot_urls: row.get(53).unwrap_or(None),
})
}
@@ -1838,7 +1871,7 @@ mod tests {
[],
|row| row.get(0),
).unwrap();
assert_eq!(version, 9);
assert_eq!(version, 10);
// All tables that should exist after the full v1-v7 migration chain
let expected_tables = [