Artifacts Associated With Ticket 076ed602e1
Ticket change [e168ed7b6d] (rid 258531) by serhiy.storchaka on 2026-10-17 10:51:12:
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
On Windows, <nowiki>[file delete -force]</nowiki> on a directory tree whose paths get longer than <tt>MAX_PATH</tt> returns without error but deletes nothing. <verbatim> set base [file join [pwd] lp] set long [file join $base {*}[lrepeat 4 [string repeat X 254]]] file mkdir $long close [open $long/leaf.txt w] file delete -force $base ;# returns "" (no error) file exists $base ;# 1, all levels and leaf.txt are still there </verbatim> Expected: the tree is deleted, or at least an error is raised. Deleting the leaf file directly works. Cause: <tt>TclpObjRemoveDirectory()</tt> (win/tclWinFCmd.c) converts the normalized path to a native string by itself with <tt>Tcl_UtfToWCharDString()</tt>, so it does not get the <tt>\\?\</tt> prefix that <tt>TclNativeCreateNativeRep()</tt> adds above <tt>MAX_PATH</tt>. <tt>TraverseWinTree()</tt> then appends components to that string. Once the path is too long, <tt>GetFileAttributesW()</tt> fails with <tt>ERROR_PATH_NOT_FOUND</tt> (ENOENT). <tt>FileDeleteCmd()</tt> (generic/tclFCmd.c) treats ENOENT after the <tt>lstat()</tt> as "deleted by someone else" and returns OK. That check was added in [0eb9289e85] (first released in 8.6.9), but it also hides an ENOENT that comes from inside the recursive traversal. Before 8.6.9 the delete presumably failed with "no such file or directory" (not checked). <nowiki>[file copy]</nowiki> of such a tree also uses <tt>TraverseWinTree()</tt> and probably fails as well (not checked). Related: [bc7925fc50] (other long path inconsistencies: <nowiki>[cd]</nowiki>, <nowiki>[glob]</nowiki>, <tt>..</tt>) and [3eace1b21f] (<nowiki>[glob]</nowiki> on deep paths). Seen on Windows 11 with the default <tt>LongPathsEnabled=0</tt> in 8.6.18, 9.0.5 and 9.1. Not tested with long paths enabled. - foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
- login: "serhiy.storchaka"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- subsystem initialized to: "37. File System"
- title initialized to:
Windows: [file delete -force] on a tree deeper than MAX_PATH returns OK and deletes nothing
- type initialized to: "Bug"
Ticket change [490dc21048] (rid 258615) by serhiy.storchaka on 2026-10-17 14:06:09:
- icomment:
Proposed fix in branch [/timeline?r=win-delete-long-path|win-delete-long-path]: the recursive delete uses the extended path prefix <tt>\\?\</tt>, so the paths inside the tree can exceed <tt>MAX_PATH</tt>. It also no longer stops at an entry that someone else deleted meanwhile (or whose deletion is pending), which left the rest of the tree behind while <nowiki>[file delete]</nowiki> returned OK. Tests winFCmd-9.5 and 9.6.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [f30d3bb3ba] (rid 259536) by serhiy.storchaka on 2026-10-20 18:11:29:
- submitter changed to: "serhiy.storchaka"