Reread source command does not update file size

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

browny
Senior Member
Senior Member
Posts: 361
Joined: 2007-09-10, 13:19 UTC

Reread source command does not update file size

Post by *browny »

I noticed it when watching progress of downloads in Firefox.
Firefox stores data in .part file, which increases it's size in the process (on completion that file would be renamed to the proper name by dropping .part suffix).
So I start a download and moved cursor in TC's panel to the .part file.

Free space on drive above file panel is updated when Reread source command would be executed (Ctrl-R, button, Show -> Reread source menu item).
But file's size below file panel stays unchanged.
The size might get updated by switching to another application and back to TC window.

Windows 10 32-bit, TC 9.0 b4.
Beta 3 behaved the same way.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50550
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This is actually a misfeature of the NTFS file system: File attributes like the size and timestamp are only updated in the directory when the file is CLOSED. You can force that by opening and closing the file yourself (if the file isn't locked by the other process). Try e.g. F3 or Alt+Enter on the file, that should instantly update the size when watching for directory changes.
Author of Total Commander
https://www.ghisler.com
browny
Senior Member
Senior Member
Posts: 361
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

ghisler(Author) wrote:This is actually a misfeature of the NTFS file system: File attributes like the size and timestamp are only updated in the directory when the file is CLOSED. You can force that by opening and closing the file yourself (if the file isn't locked by the other process). Try e.g. F3 or Alt+Enter on the file, that should instantly update the size when watching for directory changes.
It seems to be more complicated.
Today I started download in Firefox, and watched Far and Explorer (TC was not installed there). Application windows were arranged so that size could be seen in all three programs; and by clicking on captions it was possible to switch between applications.

Far is known to update it's F3 viewer in real time, so it could be expected that file size might be updated too. It does in a way, but not trivially.

Ctrl-R in Far does not update file size - just as it was with TC. The size is not updated by itself too while download is in progress.
Switching between Far and Explorer does nothing.
F5 in Explorer with noticeable delay (1-2 seconds) properly updates file size; after that Far also updates displayed size.
However, switching to Firefox updates size in Explorer and in Far without any extra key pressed.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50550
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

F5 in Explorer with noticeable delay (1-2 seconds) properly updates file size
That's interesting, apparently Explorer calls some unknown function causing NTFS to flush the changed size to the directory. If anyone knows what function that is, then I will gladly add it to Total Commander too. As you can see Far has the same problem as TC.

If you enable watching directory changes in TC Configuration - Options - Refresh, it will surely also refresh automatically when you press F5 in Explorer...
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Maybe Explorer opens all files in a dir (and this tooks 1-2 seconds)? :D
browny
Senior Member
Senior Member
Posts: 361
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

So there are no any magic, only opening and closing a file may help... if only TC could know which file has stale attributes in its directory...
browny
Senior Member
Senior Member
Posts: 361
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

MVV wrote:if only TC could know which file has stale attributes in its directory...
The one under the cursor, no? :)
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think it is easy to write a tool that will open-close focused or selected files by hotkey:)
umbra
Power Member
Power Member
Posts: 876
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

cm_ListInternalOnly + ESC always does the trick for me
Windows 10 Pro x64, Windows 11 Pro x64
browny
Senior Member
Senior Member
Posts: 361
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

umbra wrote:cm_ListInternalOnly + ESC always does the trick for me
Smart idea.
Just as suggested in the article: opening and closing file should update directory data.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Something like this should work from buttonbar button:

Code: Select all

Command: powershell.exe
Parameters: -c "ls | ? { $_ -is [IO.FileInfo] -and $_.LastWriteTime -gt ([DateTime]::Now.AddDays(-1)) } | %% { [IO.File]::Open($_.FullName, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite).Close(); }"
This command should open and close all files in current folder which were modified during last day. Perhaps it reguires playing with some file open parameters...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50550
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Maybe the Explorer is reloading the file icon? Is it an EXE file or other file with individual icon?
Author of Total Commander
https://www.ghisler.com
User avatar
HolgerK
Power Member
Power Member
Posts: 5411
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

This is an old bug which can easily avoided by turning on
"Configuration-> Options -> Icons: [x] Show overlay Icons, e.g. for links"
Sea also: German thread from 2013

Regards
Holger
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I don't think it is a bug, it is a normal NTFS behaviour. Enabling overlay icons in such case is more a workaround than a fix.
Post Reply