fs.rmSync with recursive: true follows symlinks and deletes the link target's contents
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #2049 de @RaphaelFakhri — fusionado
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
Línea de trabajo
Start in packages/build-tools/bridge-src/builtins/fs.ts, where the issue identifies rmSync and rm as using fs.statSync on the top-level path and directory entries. Check the recursive removal behavior against the reproduction, including the dangling symlink case. Done means recursive removal leaves symlink targets intact, removes dangling links, and removes the requested directory.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
In the guest, fs.rmSync(dir, { recursive: true }), fs.rm and fs.promises.rm follow symlinks. When the tree contains a symlink to a directory, the remove deletes everything inside the link target, then fails with ENOTDIR. The directory that was meant to be removed stays behind.
Node never follows symlinks in rm; it removes the link and leaves the target intact.
Reproduction
Run inside a VM:
import fs from "node:fs";
fs.mkdirSync("keep");
fs.writeFileSync("keep/data.txt", "keep");
fs.mkdirSync("doomed");
fs.symlinkSync("../keep", "doomed/link-dir");
try {
fs.rmSync("doomed", { recursive: true });
} catch (error) {
console.log(error.code);
}
console.log(fs.existsSync("doomed"), fs.readdirSync("keep"));
Host Node prints false [ 'data.txt' ].
The guest prints ENOTDIR, then true []: keep/data.txt is deleted.
A related symptom: fs.rmSync("dangling") on a symlink whose target does not exist throws ENOENT instead of removing the link.
Cause
rmSync and rm in packages/build-tools/bridge-src/builtins/fs.ts use fs.statSync for both the top-level path and each directory entry. statSync resolves symlinks, so a link to a directory is treated as a directory and recursed into.
- Lenguaje dominante
- Rust
- Estrellas
- 4.8k
- Forks
- 272
- Merge medio
- 13 h 24 min
- PR fusionados (30 d)
- 49
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rivet-dev/agentos
-
Dificultad 3/5 Medio día Aptitud para principiantes 32/100
rivet-dev/agentos#2020 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Inline JavaScript resolves dynamic import() from / instead of the working directoryPosiblemente ocupada @mittal-parth la tomó hace 32 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
rivet-dev/agentos#1973 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
Los mantenedores suelen responder en 1 día
-
Guest-execution slot counter has no near-threshold warningPosiblemente ocupada @SparshSunilNaik la tomó hace 54 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de rivet-dev/agentos
Issues similares
-
good first issue help wanted r-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
servo/rust-smallvec#792 ·
Los mantenedores suelen responder en 1 día
-
A-Unicode C-bug P-low
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
rust-lang/rustfmt#7210 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
area:sim good first issue kind:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
bitcoindevkit/bdk#2432 ·
Los mantenedores suelen responder en 3 días