[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

andry81
Member
Member
Posts: 123
Joined: 2018-11-22, 19:17 UTC

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

Post by *andry81 »

OS: Windows 8.1

The external drive is connected through AgeStar 3U2B3A.
The drive was at sleeping.
TC started and completed moving w/o an error.
The file has been erased before the drive even has started to spin.
The drive is disconnected in between.
The file was lost.
I think this is serious bug.
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 this cannot be prevented. When moving, TC waits for the "copying complete" from Windows before deleting the source. The Windows function CopyFileEx returns OK in this case because it successfully writes the file to the write cache. I don't see any way to detect your special case, even manually. You could use the option "Verify", but it would make copying at least 10 times slower.

Moderator message from: ghisler(Author) » 2024-11-14, 08:10 UTC

Moved to will not be changed
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-14, 08:10 UTC Unfortunately this cannot be prevented. When moving, TC waits for the "copying complete" from Windows before deleting the source. The Windows function CopyFileEx returns OK in this case because it successfully writes the file to the write cache. I don't see any way to detect your special case, even manually. You could use the option "Verify", but it would make copying at least 10 times slower.
Copy does work differently and WAITS the spin up.
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-14, 08:10 UTC Unfortunately this cannot be prevented. When moving, TC waits for the "copying complete" from Windows before deleting the source. The Windows function CopyFileEx returns OK in this case because it successfully writes the file to the write cache. I don't see any way to detect your special case, even manually. You could use the option "Verify", but it would make copying at least 10 times slower.
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa

MOVEFILE_WRITE_THROUGH
8 (0x8)
The function does not return until the file is actually moved on the disk.

Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns. The flush occurs at the end of the copy operation.

This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set.
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) »

MOVEFILE_WRITE_THROUGH bypasses the write cache, which makes copying painfully slow. Sorry, but Total Commander would become unusable when I used this.
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-15, 08:42 UTC MOVEFILE_WRITE_THROUGH bypasses the write cache, which makes copying painfully slow. Sorry, but Total Commander would become unusable when I used this.
You don't need write the whole file, enough to only start write the first byte. The rest can be done without the flag.
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) »

I have tried to reproduce this problem with an external USB harddisk, but failed. Here is what I tried:
1. Opened control.exe
2. Switched to "Small icons" or "Large icons"
3. Clicked on power options
4. Clicked on the option to change the current plan
5. Opened the extended options
6. Set the harddisk timeout to 15 minutes
7. Attached the USB disk
8. Copied a file to it
9. Switched to a different tab to not accidentally awaken the drive
10. Waited 15 minutes for the drive to spin down
11. Dragged a file to the tab with the USB disk, holding down shift to move the file
12. The copy progress dialog stayed up until the drive had finished spinning up and the file was copied
13. Immediately unplugged the drive after the copy dialog had disappeared
14. Re-attached the drive
-> the file had been copied successfully.
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-17, 09:04 UTC I have tried to reproduce this problem with an external USB harddisk, but failed. Here is what I tried:
I still could repro.

Mine steps:

1. Create new power plan.
2. Set sleep timeout for 1 min.
3. SHIFT-F4 and create `1.dat` with 5 bytes content (`123<lr>`) on a local drive (HDD too, but seems wake ups faster).
4. Switch the tab to the local drive.
5. Wait ~10 min (deliberately greater interval)
6. F6 to copy `1.dat` to the USB drive.

It looks like it wake ups too slowly and Windows decides to reattach it or something because of the dismount sound.
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) »

This sounds like a hardware problem, no idea how to resolve it.
Does the drive spin up when you switch to the drive in a panel before moving the file to it?
Or when the drive contents are already shown, does it spin up when you press Ctrl+R?
Then I could just refresh the directory before each move operation.
Author of Total Commander
https://www.ghisler.com
User avatar
j7n
Member
Member
Posts: 194
Joined: 2005-08-07, 21:56 UTC

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

Post by *j7n »

Do you use the Safely Remove Hardware command before disconnecting the disk? The default setting for normal USB disks in Device Manager is to not use a cache, which makes them slow for small fragmented writes. With a cache, the command must always be used.
#148174 Personal license
Running Total Commander v8.52a
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 »

j7n wrote: 2024-11-18, 13:13 UTC Do you use the Safely Remove Hardware command before disconnecting the disk?
The disconnection happens automatically by an event, not by manual disconnection, because of the Windows dismount sound. I don't know why, but suspect of some timeout in the API.
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-18, 10:18 UTC This sounds like a hardware problem, no idea how to resolve it.
I'll try to investigate it further by remove other drivers which may interfere.
User avatar
petermad
Power Member
Power Member
Posts: 16099
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

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

Post by *petermad »

2andry81
Have you tried adding the USB drive to: "Configuration" -> "Edit/Delete" -> Use compatibility mode for the following drives:" ?
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
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) »

2andry81
Could you please answer my questions?
Does the drive spin up when you switch to the drive in a panel before moving the file to it?
Or when the drive contents are already shown, does it spin up when you press Ctrl+R?
If I find a way to awaken the drive before trying to move a file, the move function shouldn't fail without error.
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 »

Does the drive spin up when you switch to the drive in a panel before moving the file to it?
Yes.
Or when the drive contents are already shown, does it spin up when you press Ctrl+R?
It based on the drive caching. Not always even the read of a file does trigger the awakening.
Post Reply