Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

compact: build the successor in a private directory and publish it atomically

Abierto
#59 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, node.js

Línea de trabajo

Start with okf/faces/lib/compact.js and read guardCompactPaths(), claimDir(), and the staging and cleanup flow. The issue also identifies Bundle.init and the sign callback as key points to trace. Add the three listed race tests, then verify that compaction refuses a changed destination and cleanup preserves replacement directories and files.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

compact() in okf/faces/lib/compact.js (branch feat/okf-autobee-v2) checks its paths once, then writes into them in place. Another process that writes into the out-dir or the staging path while a compaction runs can lose its files. The review of the compaction hardening (T13 to T18) found two such races. The owner accepted both for the first release, as a fast follow after the branch lands.

The two races

  1. The out-dir check expires before the store opens. guardCompactPaths() refuses a non-empty out-dir before the face step. Compaction then materializes, stages and awaits the sign callback. If another process creates the out-dir and writes a file into it during that window, claimDir() accepts the directory, and Bundle.init (Corestore) clears it. The foreign file is gone, and compaction reports success.
  2. Cleanup equates a path name with ownership. On a failure, compaction removes the stage when ownStage is true, and claimDir().release() removes the out-dir or the entries that it did not see at claim time. If another process replaced the stage directory, or added a file to the out-dir after the claim, cleanup deletes that directory or file.

Both races need a concurrent writer on the same paths. A single user on one machine who runs one compaction at a time does not meet them.

The full fix

  • Build the successor in a private directory that compaction creates exclusively, for example mkdtemp(<out-dir>.compact-build-), beside the out-dir.
  • Stage, ingest and verify there. Close the successor vault.
  • Publish with an atomic rename onto the out-dir. On POSIX, rename(2) of a directory fails with ENOTEMPTY or EEXIST when the destination is not empty, so a changed destination is refused, never cleared.
  • Reopen the published vault at the out-dir and return it. compact() then returns a vault that it reopened, not the one that it built. That is an API change for callers that hold the build path.
  • Cleanup removes only the private build directory and the stage that this run created. Record the device and inode of each created directory, and refuse to remove a path whose identity changed.

Tests to add

  • A sign callback that creates the out-dir and writes a file into it: compaction refuses, and the file stays.
  • A stage replaced between staging and a failure: the replacement stays.
  • A file added to the out-dir after the claim, then an init failure: the file stays.
Lenguaje dominante
JavaScript
Estrellas
0
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de indexzero/hyperdown

Todos los issues de indexzero/hyperdown

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.