1 #include "ostree_dir_repo.h"
5 #include <boost/property_tree/ini_parser.hpp>
7 #include "logging/logging.h"
9 namespace fs = boost::filesystem;
10 namespace pt = boost::property_tree;
12 bool OSTreeDirRepo::LooksValid()
const {
13 fs::path objects_dir(root_ /
"/objects");
14 fs::path refs_dir(root_ /
"/refs");
15 fs::path config_file(root_ /
"/config");
16 if (fs::is_directory(objects_dir) && fs::is_directory(refs_dir) && fs::is_regular(config_file)) {
19 pt::read_ini(config_file.string(), config);
20 if (config.get<std::string>(
"core.mode") !=
"archive-z2") {
21 LOG_WARNING <<
"OSTree repo is not in archive-z2 format";
26 }
catch (
const pt::ini_parser_error &error) {
27 LOG_WARNING <<
"Couldn't parse OSTree config file: " << config_file;
29 }
catch (
const pt::ptree_error &error) {
30 LOG_WARNING <<
"Could not find core.mode in OSTree config file";
38 OSTreeRef OSTreeDirRepo::GetRef(
const std::string &refname)
const {
return OSTreeRef(*
this, refname); }
40 bool OSTreeDirRepo::FetchObject(
const boost::filesystem::path &path)
const {
41 return fs::is_regular_file((root_ / path).
string());