TeeJee.FileSystem.file_write() uses non-atomic delete + create, risking File exists collisions on rsync-log-changes
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend
Línea de trabajo
Start with file_write() in src/Utility/TeeJee.FileSystem.vala (around lines 165-185) and the finish_called flag in src/Utility/AsyncTask.vala (around lines 295-298), then check the callers RsyncTask.finish_task() and RsyncTask.parse_log(). Confirm whether replacing the delete-then-create sequence with an atomic replace preserves the current behaviour for existing callers. Done means both spots are hardened without changing results, which needs confirmation from a maintainer since the issue is a proposal rather than a reproduced bug.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
While investigating Error opening file ".../rsync-log-changes": File exists during fast rsync snapshot runs on Timeshift 25.12.4, I found that the primary trigger was the dual-thread finish() race fixed in #552 (c112e86).
However, inspecting src/Utility/TeeJee.FileSystem.vala and src/Utility/AsyncTask.vala after #552 shows two remaining defensive edge cases that could still allow File exists errors or non-atomic writes if file_write() or finish() is ever invoked concurrently:
1. Non-atomic file_write() (src/Utility/TeeJee.FileSystem.vala:165-185)
Currently, file_write() performs a separate existence check, delete, and FileCreateFlags.NONE creation:
var file = File.new_for_path (file_path);
if (file.query_exists ()) {
file.delete ();
}
var file_stream = file.create (FileCreateFlags.NONE);
If two callers (such as RsyncTask.finish_task() and RsyncTask.parse_log()) ever target the same path concurrently—or if a snapshot is interrupted mid-write—this TOCTOU sequence can fail with File exists or leave a truncated rsync-log-changes file.
Using file.replace(null, false, FileCreateFlags.REPLACE_DESTINATION) (or File.replace_contents()) would make file_write() atomic and eliminate File exists collisions across all callers.
2. Non-atomic finish_called guard (src/Utility/AsyncTask.vala:295-298)
#552 cleanly serializes finish() via wait_and_finish(), so there is currently only one caller. Hardening finish_called with GLib.AtomicInt (e.g., AtomicInt.compare_and_exchange(ref finish_called, 0, 1)) would ensure finish() remains thread-safe if any subclass or future change ever calls it directly.
Environment
- Timeshift 25.12.4 (Linux Mint 22.3) running on an older Apple iMac
- An external FireWire drive is the snapshot target where
rsynccompletes in ~35s if no major changes have been made
- Lenguaje dominante
- Vala
- Estrellas
- 4.3k
- Forks
- 162
- 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
- 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 linuxmint/timeshift
-
Delete snapshots: number mismatchPosiblemente ocupada @EthanNoble la tomó hace 6 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
-
License parsing with GitHubAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Dificultad 3/5 Medio día Aptitud para principiantes 55/100
Todos los issues de linuxmint/timeshift
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
PixelPlayerHQ/PixelPlayerOSS#254 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
389ds/389-ds-base#8152 ·
Los mantenedores suelen responder en 2 días
-
Bug feat:Syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
ignatov/intellij-erlang#1342 ·
Los mantenedores suelen responder en 1 día
-
intcomma returns exponential notation for large floatsPosiblemente ocupada @Omarinho12345 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
python-humanize/humanize#521 ·
Los mantenedores suelen responder en 1 día
-
🧑💻 tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
guibranco/gstraccini-bot-service#1206 ·
Los mantenedores suelen responder en 1 día