fix(jobs): autodetectar distro WSL + normalizar separadores UNC (issue 0026)

El usuario reportaba "no enrichers for url" en Windows. Tres bugs:

1. resolve_registry_root tenia el fallback hardcoded a "Ubuntu" pero la
   distro real era "Ubuntu-22.04". Reemplazado por detect_wsl_distro()
   que sondea las distros comunes (Ubuntu, Ubuntu-24.04, Ubuntu-22.04,
   Ubuntu-20.04, Debian, kali-linux, Fedora, openSUSE-Tumbleweed) y se
   queda con la primera cuyo UNC tenga registry.db.
2. enrichers_load construia paths con mixed separators
   ("\\\\wsl.localhost\\Ubuntu-22.04\\...\\enrichers/foo/manifest.yaml")
   que confunden a opendir de MinGW. Ahora normaliza todo a backslashes
   en Windows antes de opendir + concatena con el separador nativo.
3. El menu "Run enricher" decia simplemente "(no enrichers para tipo X)"
   sin distinguir si era 0/N (no se carga ninguno) o N>0/M (existen pero
   ninguno aplica). Ahora muestra "(no enrichers cargados — revisa
   FN_REGISTRY_ROOT)" vs "(0/4 enrichers para tipo 'url')".

Si el usuario tiene una distro con nombre raro, sigue pudiendo setear
FN_REGISTRY_ROOT explicitamente.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-01 19:27:28 +02:00
parent 598e6fcdd4
commit 4281f3ccb2
2 changed files with 63 additions and 17 deletions
+20 -5
View File
@@ -108,19 +108,34 @@ int enrichers_load(const char* enrichers_dir) {
g_enrichers.clear();
if (!enrichers_dir || !*enrichers_dir) return -1;
DIR* d = opendir(enrichers_dir);
if (!d) return -1;
// En Windows los UNC paths esperan backslashes consistentes; mixed
// separators (`\\wsl$\<distro>\foo/bar`) confunden a opendir de MinGW.
std::string dir = enrichers_dir;
#ifdef _WIN32
for (char& c : dir) if (c == '/') c = '\\';
#endif
DIR* d = opendir(dir.c_str());
if (!d) {
std::fprintf(stderr, "[enrichers] opendir failed: %s\n", dir.c_str());
return -1;
}
struct dirent* ent;
while ((ent = readdir(d)) != nullptr) {
if (ent->d_name[0] == '.') continue;
std::string sub = std::string(enrichers_dir) + "/" + ent->d_name;
#ifdef _WIN32
const char sep = '\\';
#else
const char sep = '/';
#endif
std::string sub = dir + sep + ent->d_name;
struct stat st{};
if (stat(sub.c_str(), &st) != 0 || !S_ISDIR(st.st_mode)) continue;
std::string manifest = sub + "/manifest.yaml";
std::string runpy = sub + "/run.py";
std::string manifest = sub + sep + "manifest.yaml";
std::string runpy = sub + sep + "run.py";
if (stat(manifest.c_str(), &st) != 0) continue;
if (stat(runpy.c_str(), &st) != 0) continue;