You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FileMoverTask: autoincrement applies to the whole path (dot in a directory name, numeric suffix in the file name) #240
With autoincrement: true, FileMoverTask::makeFilenameUnique() applies its regex /^(.*?)(-\d+)?(\.[^.]*)$/ to the whole path instead of the file name:
File without extension, directory containing a dot: the "extension" is taken in the directory name, and the task tries to move the file into a directory that does not exist.
File name ending with a numeric suffix: the suffix is considered as a previous increment and replaced: report-2024.csv becomes report-1.csv (part of the name is lost, and it may collide with another file).
Input /tmp/repro.d/src/file, with /tmp/repro.d/dest/file already existing:
Symfony\Component\Filesystem\Exception\IOException: Cannot rename "/tmp/repro.d/src/file" to "/tmp/repro-1.d/dest/file": rename(...): No such file or directory
Expected: the file is moved to /tmp/repro.d/dest/file-1.
Input /tmp/repro.d/src/report-2024.csv, with /tmp/repro.d/dest/report-2024.csv already existing: the output is /tmp/repro.d/dest/report-1.csv.
Expected: /tmp/repro.d/dest/report-2024-1.csv.
Reproduced on main (ad31c1f), PHP 8.5, Symfony 8.1, by calling the task / transformer directly. Found while adding the missing tests of #197.
Proposed fix
Apply the increment on the base name only (pathinfo() / dirname()), and always append -N to the original name (name-1.ext, name-2.ext...) instead of replacing an existing numeric suffix. Update file_mover_task.md, add tests.
Requirements
Documentation updates
Reference
Cookbooks
Changelog
Unit tests
Breaking changes
Case 1 currently fails. Case 2 changes the generated name of files whose name ends with -<digits> (report-2024-1.csv instead of report-1.csv).
Activity
Merge pull request #248 from cleverage/240