cli: Allow `init` without running node

This commit is contained in:
Alexis Sellier 2023-03-06 12:12:33 +01:00
parent e69be6051d
commit c8c44c884c
No known key found for this signature in database
2 changed files with 13 additions and 4 deletions

View File

@ -210,7 +210,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
Ok((id, doc, _)) => { Ok((id, doc, _)) => {
let proj = doc.project()?; let proj = doc.project()?;
if options.track { if options.track && node.is_running() {
// It's important to track our own repositories to make sure that our node signals // It's important to track our own repositories to make sure that our node signals
// interest for them. This ensures that messages relating to them are relayed to us. // interest for them. This ensures that messages relating to them are relayed to us.
node.track_repo(id)?; node.track_repo(id)?;

View File

@ -359,9 +359,18 @@ where
for (id, addr) in addrs { for (id, addr) in addrs {
self.connect(id, addr); self.connect(id, addr);
} }
// Ensure that our inventory is recorded in our routing table. // Ensure that our inventory is recorded in our routing table, and we are tracking
for id in self.storage.inventory()? { // all of it. It can happen that inventory is not properly tracked if for eg. the
self.routing.insert(id, self.node_id(), time.as_millis())?; // user creates a new repository while the node is stopped.
for rid in self.storage.inventory()? {
self.routing.insert(rid, self.node_id(), time.as_millis())?;
if self
.track_repo(&rid, tracking::Scope::All)
.expect("Service::command: error tracking repository")
{
info!(target: "service", "Tracking local repository {rid}");
}
} }
// Setup subscription filter for tracked repos. // Setup subscription filter for tracked repos.
self.filter = Filter::new( self.filter = Filter::new(