[TC11.50B2] TC moved file to not yet spinned up external USB drive

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50824
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive

Post by *ghisler(Author) »

OK, I will try calling FindFirstFile before trying to copy or move files. It it takes longer than a second, I will wait another second and call it again. Since my USB disks don't have this problem, I would appreciate if you could test this change after the release of beta 7.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50824
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive

Post by *ghisler(Author) »

Unfortunately calling FindFirstFile did not wake up my USB drive. The only way to make it wake up was to actually cause a write operation, e.g. by changing the attributes of the parent directory. Setting it to the same value it already had did NOT cause a spin up! Therefore I will not use this method for now.

Instead I'm checking whether it helps to listen to WM_DEVICECHANGE messages, which are sent for example when external drives are being disconnected (which you described above). But I don't know whether the message is sent quickly enough to prevent TC from deleting the file after copying it to the disconnected drive. Could you try it with some test file, please? You should get an English warning that the drive was removed. It may only work with larger files, though.
Author of Total Commander
https://www.ghisler.com
andry81
Member
Member
Posts: 123
Joined: 2018-11-22, 19:17 UTC

Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive

Post by *andry81 »

ghisler(Author) wrote: 2024-11-20, 17:51 UTC Unfortunately calling FindFirstFile did not wake up my USB drive. The only way to make it wake up was to actually cause a write operation, e.g. by changing the attributes of the parent directory. Setting it to the same value it already had did NOT cause a spin up! Therefore I will not use this method for now.

Instead I'm checking whether it helps to listen to WM_DEVICECHANGE messages, which are sent for example when external drives are being disconnected (which you described above). But I don't know whether the message is sent quickly enough to prevent TC from deleting the file after copying it to the disconnected drive. Could you try it with some test file, please? You should get an English warning that the drive was removed. It may only work with larger files, though.
Why not just call WriteFile with 0 bytes and with the flag at first writing file?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 7008
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive

Post by *Horst.Epp »

andry81 wrote: 2024-11-21, 11:40 UTC ...
Why not just call WriteFile with 0 bytes and with the flag at first writing file?
Hopefully not as TC default just to fix a problem only reported once.
Windows 11 Home, Version 24H2 (OS Build 26100.4351)
TC 11.55 RC6 x64 / x86
Everything 1.5.0.1395a (x64), Everything Toolbar 1.5.5.0, Listary Pro 6.3.2.88
QAP 11.9.0.3 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50824
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive

Post by *ghisler(Author) »

Why not just call WriteFile with 0 bytes and with the flag at first writing file?
Because the default copy method does not use CreateFile/ReadFile/WriteFile but uses CopyFileEx. Normally CopyFileEx fails when it can't spin up the drive, so TC doesn't delete the original file. But andry81's strange drive disconnects during spin up, and CopyFileEx still reports success. I hope that I can detect the disconnect before trying to delete the file.
Author of Total Commander
https://www.ghisler.com
Post Reply