fs.cpSync / fs.cp / fs.promises.cp fails when src/dest args are Buffer
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
Version
All
Platform
All
Subsystem
fs
What steps will reproduce the bug?
const { cpSync, cp, promises } = require('node:fs');
cpSync(Buffer.from('dirA'), Buffer.from('dirB'), { recursive: true, filter(...args) { console.log(...args); return true; } }); // throws
cp(Buffer.from('dirA'), Buffer.from('dirB'), { recursive: true, filter(...args) { console.log(...args); return true; } }, (err) => {
console.log(err); // errors
});
promises.cp(Buffer.from('dirA'), Buffer.from('dirB'), { recursive: true, filter(...args) { console.log(...args); return true; } }); // rejects
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
It should just work without throwing. The filter function should be called with the option to receive the path as either a string, Buffer, or URL.
What do you see instead?
It throws.
Additional information
The issue here is that the underlying implementation assumes that the paths are strings and tries to use the path.join function to concatenate them, which obviously does not work for Buffer and URL. The implementation has to be able to support Buffer and URL paths in order to properly support arbitrary text encodings in file names etc. Unfortunately, because of the way the callback is designed, it's not clear that there is an immediate non-breaking fix ready available.
@dario-piotrowicz @cjihrig @anonrig
Guía de contribución
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.
Línea de trabajo
Comienza con los puntos de entrada fs.cpSync, fs.cp y fs.promises.cp y reproduce el ejemplo de ruta Buffer del issue. Rastrea el manejo de rutas y los argumentos del callback de filtro para entradas de tipo string, Buffer y URL. La tarea está terminada cuando las tres API aceptan rutas Buffer y URL sin lanzar excepciones, y el filtro recibe un valor de ruta compatible.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, nodejs
- Área
- operating-systems
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100