diff options
Diffstat (limited to 'src/index.rs')
-rw-r--r-- | src/index.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/index.rs b/src/index.rs index f7300da..9386e73 100644 --- a/src/index.rs +++ b/src/index.rs @@ -75,6 +75,10 @@ impl Index { pub fn find_generations(&self) -> IndexResult<Vec<ChunkId>> { sql::find_generations(&self.conn) } + + pub fn all_chunks(&self) -> IndexResult<Vec<ChunkId>> { + sql::find_chunk_ids(&self.conn) + } } #[cfg(test)] @@ -243,6 +247,17 @@ mod sql { Ok(ids) } + pub fn find_chunk_ids(conn: &Connection) -> IndexResult<Vec<ChunkId>> { + let mut stmt = conn.prepare("SELECT id FROM chunks WHERE generation IS 0")?; + let iter = stmt.query_map(params![], |row| row_to_id(row))?; + let mut ids = vec![]; + for x in iter { + let x = x?; + ids.push(x); + } + Ok(ids) + } + fn row_to_meta(row: &Row) -> rusqlite::Result<ChunkMeta> { let sha256: String = row.get(row.column_index("sha256")?)?; let generation: i32 = row.get(row.column_index("generation")?)?; |