Add function to check if files are present

This commit is contained in:
Patrick Lühne 2018-09-26 20:33:53 +02:00
parent 9196f54c62
commit 2af028acae
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 38 additions and 1 deletions

View File

@ -40,7 +40,14 @@ fn main()
let instance_domain = instance["domain"].as_str().unwrap();
let instance_number = instance["instance"].as_i64().unwrap();
println!("[{}, {}, {}/{}/{}]", configuration_id, instance_set_id, instance_ipc, instance_domain, instance_number);
let file_name = format!("{}/{}/{}", instance_ipc, instance_domain, instance_number);
if (benchmark_repository.file_exists(Path::new(&file_name), "test-results"))
{
continue;
}
println!("to do: [{}, {}, {}/{}/{}]", configuration_id, instance_set_id, instance_ipc, instance_domain, instance_number);
}
}
}

View File

@ -283,6 +283,36 @@ impl BenchmarkRepository
remote.push(&[&push_refspec], Some(&mut push_options)).expect("couldnt push");
}
pub fn file_exists(&self, file_path: &Path, branch_name: &str) -> bool
{
let tip_reference_name = format!("refs/remotes/origin/{}", branch_name);
let tip_reference = match self.repository.find_reference(&tip_reference_name)
{
Ok(value) => value,
Err(error) => panic!("Could not find reference “{}”: {}", tip_reference_name, error),
};
let tree = match tip_reference.peel_to_tree()
{
Ok(value) => value,
Err(error) => panic!("Could not peel reference to tree: {}", error),
};
let object_id = match tree.get_path(file_path)
{
Ok(tree_entry) => tree_entry.id(),
Err(error) => return false,
};
let blob = match self.repository.find_blob(object_id)
{
Ok(blob) => blob,
Err(error) => return false,
};
true
}
pub fn read_file(&self, file_path: &Path, branch_name: &str) -> Option<String>
{
let tip_reference_name = format!("refs/remotes/origin/{}", branch_name);