fast check for autocomplete!
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
#include <chrono>
|
||||
#include <libassert/assert.hpp>
|
||||
@@ -50,7 +48,7 @@
|
||||
return std::filesystem::exists(path);
|
||||
}
|
||||
|
||||
template_info template_source_local::get_template_info(const std::string& template_name) {
|
||||
template_info template_source_local::get_template_info(const std::string& template_name, bool fast) {
|
||||
std::filesystem::path path = mLocalPath / template_name;
|
||||
|
||||
if (!std::filesystem::exists(path))
|
||||
@@ -184,7 +182,7 @@
|
||||
return std::filesystem::exists(template_cache_dir);
|
||||
}
|
||||
|
||||
template_info template_source_registry::get_template_info(const std::string& template_name)
|
||||
template_info template_source_registry::get_template_info(const std::string& template_name, bool fast)
|
||||
{
|
||||
// Get cache directory
|
||||
std::filesystem::path cache_dir = get_cache_dir();
|
||||
@@ -204,6 +202,15 @@
|
||||
return template_info();
|
||||
}
|
||||
|
||||
// fast: don't bother updating anything - if we have a cached version use that.
|
||||
if (fast && have_cache) {
|
||||
return template_info(
|
||||
template_name,
|
||||
"Registry: " + mRegistry.name + " (cached)",
|
||||
template_cache_dir
|
||||
);
|
||||
}
|
||||
|
||||
// Get metadata from registry to check version
|
||||
std::string meta_url = mRegistry.url + "/meta/" + template_name + ":latest";
|
||||
|
||||
@@ -395,7 +402,7 @@
|
||||
bool template_source_registry::template_command_exists(const std::string& template_name, const std::string& command)
|
||||
{
|
||||
// Get template info to ensure it's downloaded and cached
|
||||
auto tinfo = get_template_info(template_name);
|
||||
auto tinfo = get_template_info(template_name, false);
|
||||
if (!tinfo.is_set()) {
|
||||
return false;
|
||||
}
|
||||
@@ -460,12 +467,12 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
template_info template_manager::get_template_info(const std::string &template_name) const
|
||||
template_info template_manager::get_template_info(const std::string &template_name, bool fast) const
|
||||
{
|
||||
ASSERT(mLoaded && mSources.size() > 0, "Template manager not loaded, or no template sources found.");
|
||||
template_source_interface* source = get_source(template_name);
|
||||
if (source)
|
||||
return source->get_template_info(template_name);
|
||||
return source->get_template_info(template_name, fast);
|
||||
|
||||
// fail
|
||||
return template_info();
|
||||
@@ -498,7 +505,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
auto tinfo = get_template_info(template_name);
|
||||
auto tinfo = get_template_info(template_name, false);
|
||||
if (tinfo.is_set()) {
|
||||
error << "Template '" << template_name << "' already exists at " << tinfo.locationID() << std::endl;
|
||||
return false;
|
||||
@@ -583,8 +590,8 @@
|
||||
}
|
||||
|
||||
// Add registry sources - these should always be added
|
||||
auto registry_urls = gConfig().get_template_registry_urls();
|
||||
for (const auto& url : registry_urls) {
|
||||
std::vector<tRegistryEntry> registry_urls = gConfig().get_template_registry_urls();
|
||||
for (const tRegistryEntry & url : registry_urls) {
|
||||
mSources.push_back(std::make_unique<template_source_registry>(url));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user