Skip to content

Commit 0701090

Browse files
committed
Update file deletion logic in upgrade accounts.
1 parent 23d6c9b commit 0701090

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

crates/backend/src/audit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub async fn append_audit_events(events: &[AuditEvent]) -> Result<()> {
4646
provider.append_audit_events(events).await?;
4747
}
4848
}
49+
50+
// For test specs we don't require an audit trail
4951
#[cfg(debug_assertions)]
5052
{
5153
if let Some(providers) = providers() {

crates/core/src/paths.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,19 @@ impl Paths {
330330
/// account-level preferences.
331331
pub fn preferences_file(&self) -> PathBuf {
332332
let mut path = if self.is_global() {
333-
self.documents_dir().join(PREFERENCES_FILE)
333+
self.global_preferences_file()
334334
} else {
335335
self.user_dir().join(PREFERENCES_FILE)
336336
};
337337
path.set_extension(JSON_EXT);
338338
path
339339
}
340340

341+
/// Path to the global preferences file.
342+
pub fn global_preferences_file(&self) -> PathBuf {
343+
self.documents_dir().join(PREFERENCES_FILE)
344+
}
345+
341346
/// Path to the file used to store account-level system messages.
342347
///
343348
/// # Panics

crates/database_upgrader/src/upgrader/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ async fn delete_stale_files(
435435
let mut files = vec![
436436
options.paths.identity_dir().to_owned(),
437437
options.paths.audit_file().to_owned(),
438+
options.paths.global_preferences_file().to_owned(),
438439
];
439440

440441
for account in accounts {
@@ -461,5 +462,12 @@ async fn delete_stale_files(
461462
}
462463
}
463464

465+
// Can error if the local directory is not empty!
466+
if let Err(error) = vfs::remove_dir(options.paths.local_dir()).await {
467+
tracing::error!(
468+
error = %error,
469+
"updgrade_accounts::remove_local_dir");
470+
}
471+
464472
Ok(files)
465473
}

0 commit comments

Comments
 (0)