diff --git a/src/app.rs b/src/app.rs index 657c54e..75b968f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -45,6 +45,7 @@ pub struct FolderStatus { pub directory_count: usize, pub deleted_count: usize, pub conflict_count: usize, + pub history_revision_count: u64, pub last_successful_sync: Option, pub last_sync_error: Option, } @@ -299,6 +300,7 @@ impl AppaService { .keys() .filter(|path| path.contains(" (conflict-")) .count(), + history_revision_count: self.state_store.manifest_history_count(folder.id)?, last_successful_sync: self.state_store.last_successful_sync(folder.id)?, last_sync_error: self.state_store.last_sync_error(folder.id)?, folder, diff --git a/src/cli.rs b/src/cli.rs index 4fc1981..18c92a9 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -426,7 +426,7 @@ fn print_status(appa: &AppaService, folder: Option, json: bool) -> anyh } for status in statuses { println!( - "{}\nActive members: {}\nKnown peers: {}\nFiles: {}\nDirectories: {}\nTombstones: {}\nConflicts: {}\nLast successful sync: {}\nLast sync error: {}", + "{}\nActive members: {}\nKnown peers: {}\nFiles: {}\nDirectories: {}\nTombstones: {}\nConflicts: {}\nHistory revisions: {}\nLast successful sync: {}\nLast sync error: {}", status.folder.path.display(), status.member_count, status.peers.len(), @@ -434,6 +434,7 @@ fn print_status(appa: &AppaService, folder: Option, json: bool) -> anyh status.directory_count, status.deleted_count, status.conflict_count, + status.history_revision_count, status .last_successful_sync .map(|time| time.to_string()) @@ -467,6 +468,7 @@ fn status_as_json(status: &crate::app::FolderStatus) -> serde_json::Value { "directories": status.directory_count, "tombstones": status.deleted_count, "conflicts": status.conflict_count, + "history_revisions": status.history_revision_count, "last_successful_sync": status.last_successful_sync.map(|time| time.to_string()), "last_sync_error": status.last_sync_error, }) diff --git a/src/storage.rs b/src/storage.rs index e2daec8..9ce8949 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -507,6 +507,15 @@ impl StateStore { .collect() } + pub fn manifest_history_count(&self, folder_id: FolderId) -> anyhow::Result { + let count: i64 = self.connection.query_row( + "SELECT COUNT(*) FROM manifest_history WHERE folder_id = ?1", + params![folder_id.to_string()], + |row| row.get(0), + )?; + u64::try_from(count).map_err(Into::into) + } + pub fn manifest_revision( &self, folder_id: FolderId,