http://bugs.winehq.org/show_bug.cgi?id=21156
Damjan Jovanovic damjan.jov@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |damjan.jov@gmail.com
--- Comment #19 from Damjan Jovanovic damjan.jov@gmail.com 2010-06-05 04:14:32 --- 42 votes in < 6 months? Must be a popular app :-).
ReplaceFileW is not the problem here. Some additional tracing in ReplaceFileW shows that by the time ReplaceFileW is called, the files passed to it are already empty.
Why? A +file,+relay,+tid trace shows that earlier the torrent file (28316 bytes) got written correctly, then CopyFileW gets called with the same source and destination and the overwrite option on true, which truncates the file to 0 bytes:
---snip--- 001d:Call KERNEL32.CopyFileW(0115e684 L"C:\users\dacha\Temp\utt600e.tmp.new",0115e258 L"C:\users\dacha\Temp\utt600e.tmp.new",00000000) ret=0043b083 ... 001d:Ret KERNEL32.CopyFileW() retval=00000001 ret=0043b083 001d:Call KERNEL32.ReplaceFileW(0029f8c0 L"C:\users\dacha\Temp\utt600e.tmp",0115e258 L"C:\users\dacha\Temp\utt600e.tmp.new",0115e460 L"C:\users\dacha\Temp\utt600e.tmp.31585.tmp",00000002,00000000,00000000) ret=0043b09b ---snip---
Case in point: hacking CopyFileW to return success immediately if the source and destination are the same, makes adding the Torrent succeed.
Maybe that's what Windows also does? I will test.