feat(graph_explorer): adopta convencion local_files/
Sustituye paths hardcodeados (graph_explorer.db, graph_explorer.ini,
projects/) por resolutores que apuntan a <exe_dir>/local_files/.
- project_manager: k_projects_dir y k_settings_file pasan a ser
helpers projects_root() / settings_path() que llaman a
fn::local_path internamente. Layout en disco documentado en el
comentario de cabecera del .h.
- main.cpp: el modo legacy y el fallback de jobs_init usan
fn::local_path('graph_explorer.db') en lugar de relativo al cwd.
Junto al cambio del framework (commit f102aba9), graph_explorer
se distribuye con su carpeta limpia: solo .exe + duckdb.dll +
TTFs + enrichers/ + runtime/. Todo el estado del usuario vive
en local_files/.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-7
@@ -1,5 +1,7 @@
|
||||
#include "project_manager.h"
|
||||
|
||||
#include "../../../../cpp/framework/app_base.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -20,6 +22,14 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace ge {
|
||||
|
||||
// Helpers de paths — resuelven contra <exe_dir>/local_files/.
|
||||
const char* projects_root() {
|
||||
return fn::local_path(k_projects_subdir);
|
||||
}
|
||||
const char* settings_path() {
|
||||
return fn::local_path(k_settings_basename);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DDL embebido (operations.db schema)
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -217,7 +227,7 @@ bool project_validate_slug(const char* name, std::string* error_msg) {
|
||||
ProjectPaths project_paths(const char* slug) {
|
||||
ProjectPaths p;
|
||||
if (!slug || !*slug) return p;
|
||||
fs::path root = fs::path(k_projects_dir) / slug;
|
||||
fs::path root = fs::path(projects_root()) / slug;
|
||||
p.root_dir = root.string();
|
||||
p.operations_db = (root / "operations.db").string();
|
||||
p.types_yaml = (root / "types.yaml").string();
|
||||
@@ -231,7 +241,7 @@ ProjectPaths project_paths(const char* slug) {
|
||||
|
||||
bool projects_root_ensure() {
|
||||
std::error_code ec;
|
||||
fs::create_directories(k_projects_dir, ec);
|
||||
fs::create_directories(projects_root(), ec);
|
||||
return !ec;
|
||||
}
|
||||
|
||||
@@ -239,8 +249,8 @@ bool project_list(std::vector<std::string>* out) {
|
||||
if (!out) return false;
|
||||
out->clear();
|
||||
std::error_code ec;
|
||||
if (!fs::exists(k_projects_dir, ec)) return true;
|
||||
for (auto& e : fs::directory_iterator(k_projects_dir, ec)) {
|
||||
if (!fs::exists(projects_root(), ec)) return true;
|
||||
for (auto& e : fs::directory_iterator(projects_root(), ec)) {
|
||||
if (ec) break;
|
||||
if (!e.is_directory()) continue;
|
||||
std::string slug = e.path().filename().string();
|
||||
@@ -346,7 +356,7 @@ bool project_create(const char* slug, std::string* error_msg) {
|
||||
|
||||
bool projects_migrate_legacy_layout() {
|
||||
std::error_code ec;
|
||||
if (fs::exists(k_projects_dir, ec)) return true; // ya migrado o creado
|
||||
if (fs::exists(projects_root(), ec)) return true; // ya migrado o creado
|
||||
|
||||
bool has_operations = fs::exists("operations.db", ec);
|
||||
bool has_layout = fs::exists("graph_explorer.db", ec);
|
||||
@@ -423,7 +433,7 @@ static std::vector<std::string> split_csv(const std::string& s) {
|
||||
bool project_settings_load(ProjectSettings* out) {
|
||||
if (!out) return false;
|
||||
*out = {};
|
||||
std::ifstream in(k_settings_file);
|
||||
std::ifstream in(settings_path());
|
||||
if (!in) return true; // no es error: archivo aun no existe
|
||||
std::string line;
|
||||
while (std::getline(in, line)) {
|
||||
@@ -440,7 +450,7 @@ bool project_settings_load(ProjectSettings* out) {
|
||||
}
|
||||
|
||||
bool project_settings_save(const ProjectSettings& s) {
|
||||
std::ofstream out(k_settings_file);
|
||||
std::ofstream out(settings_path());
|
||||
if (!out) return false;
|
||||
out << "# graph_explorer.ini — autogenerado, editable\n";
|
||||
out << "last_active = " << s.last_active << "\n";
|
||||
|
||||
Reference in New Issue
Block a user