Fix second audit findings and restore crash detection dialog
This commit is contained in:
@@ -194,8 +194,7 @@ pub struct SandboxProfileRecord {
|
||||
}
|
||||
|
||||
fn db_path() -> PathBuf {
|
||||
let data_dir = dirs::data_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("~/.local/share"))
|
||||
let data_dir = crate::config::data_dir_fallback()
|
||||
.join("driftwood");
|
||||
std::fs::create_dir_all(&data_dir).ok();
|
||||
data_dir.join("driftwood.db")
|
||||
@@ -748,7 +747,7 @@ impl Database {
|
||||
is_executable: bool,
|
||||
file_modified: Option<&str>,
|
||||
) -> SqlResult<i64> {
|
||||
self.conn.execute(
|
||||
let id: i64 = self.conn.query_row(
|
||||
"INSERT INTO appimages (path, filename, appimage_type, size_bytes, is_executable, file_modified)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6)
|
||||
ON CONFLICT(path) DO UPDATE SET
|
||||
@@ -757,17 +756,9 @@ impl Database {
|
||||
size_bytes = excluded.size_bytes,
|
||||
is_executable = excluded.is_executable,
|
||||
file_modified = excluded.file_modified,
|
||||
last_scanned = datetime('now')",
|
||||
last_scanned = datetime('now')
|
||||
RETURNING id",
|
||||
params![path, filename, appimage_type, size_bytes, is_executable, file_modified],
|
||||
)?;
|
||||
// last_insert_rowid() returns 0 for ON CONFLICT UPDATE, so query the actual id
|
||||
let id = self.conn.last_insert_rowid();
|
||||
if id != 0 {
|
||||
return Ok(id);
|
||||
}
|
||||
let id: i64 = self.conn.query_row(
|
||||
"SELECT id FROM appimages WHERE path = ?1",
|
||||
params![path],
|
||||
|row| row.get(0),
|
||||
)?;
|
||||
Ok(id)
|
||||
|
||||
Reference in New Issue
Block a user