Skip to content

Commit

Permalink
IndexFile::insert(): Add dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkofler committed Oct 11, 2024
1 parent b344f89 commit 87e2ea9
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/files/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use log::debug;

use crate::{
error::{Error, ErrorExt},
model::{Object, ObjectCompression, ObjectDB, ObjectType},
model::{Object, ObjectCompression, ObjectDB, ObjectID, ObjectType},
util::{fs::IndexCommand, Packable, Unpackable},
};

Expand Down Expand Up @@ -67,6 +67,24 @@ impl IndexFile {
Ok(())
}

/// Returns a vector of all objects used by this index file
pub fn get_objects(&self) -> Vec<ObjectID> {
let mut res = Vec::new();

for cmd in &self.commands {
if let IndexCommand::File {
info: _,
name: _,
oid,
} = cmd
{
res.push(oid.clone())
}
}

res
}

/// Inserts this index into `object_db`
/// # Arguments
/// * `object_db` - The objet db to insert the formula into
Expand All @@ -87,7 +105,7 @@ impl IndexFile {
ObjectType::AcaciaIndex,
compression,
true,
Vec::new(),
self.get_objects(),
)
}
}
Expand Down

0 comments on commit 87e2ea9

Please sign in to comment.