Author Topic: Refresh file info in a directory  (Read 14042 times)

nietrupek

  • Newbie
  • *
  • Posts: 12
    • View Profile
Refresh file info in a directory
« on: May 02, 2021, 12:44:12 »
Windows 10, local filesystem (C: drive).

When I download large file using browser, a temporary file (largefile.mp4.part) is created. MC shows this file with size of approx. 32kB. The file is growing, but its size is still shown as 32kB. Pressing F2 (or Refresh icon) does nothing. Also DIR command shows file size as 32kB.

But when I do one of the following:
- select file and press F3 (View file)
- use Cygwin's 'ls -l' command
proper file size is immediately shown in MC. DIR command also returns refreshed file size info.

Apparently MC's F3 command (and Cygwin's ls) do something that forces Windows to "wake up" and report proper file info to the caller.

Here's my feature request: change F2/Refresh to deal properly with situation described above.


Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4407
    • View Profile
    • Multi Commander
Re: Refresh file info in a directory
« Reply #1 on: May 03, 2021, 11:30:07 »
This is now NTFS work. It is a optimization in the filesystem.. But if a forced open of the file is done before the file is completed Windows will then flush the data it has so far. However this can slow down the writing of data or make it split it into more segment making it more fragmented.

Auto force opening all files on refresh would be slow. The whole refresh process would be slower and it will also destroy the reason why NTFS is doing this. There is reason why Windows does this.


nietrupek

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Refresh file info in a directory
« Reply #2 on: May 09, 2021, 18:57:00 »
Compile this:
Code: [Select]
#include <glob.h>
int main (void)
{
glob_t globbuf;
glob("*", GLOB_NOSORT, NULL, &globbuf);
return 0;
}
and link with standard Cygwin's DLL. Running resulting program in any directory does the trick. And I don't think that any hidden fopen() calls are involved.

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4407
    • View Profile
    • Multi Commander
Re: Refresh file info in a directory
« Reply #3 on: May 10, 2021, 07:57:34 »
Compile this:
Code: [Select]
#include <glob.h>
int main (void)
{
glob_t globbuf;
glob("*", GLOB_NOSORT, NULL, &globbuf);
return 0;
}
and link with standard Cygwin's DLL. Running resulting program in any directory does the trick. And I don't think that any hidden fopen() calls are involved.

Don't know what they are doing. But I think they are opening the files to get file information, while normal Windows API will get all that information from the directory entry without opening every individual file handle. The directory entry is updated when a file is closed. And all this are because of performance improvements of NTFS. Opening every single file will make a dir scan a lot slower.. Specially over the network.

Also MC is not using cygwin and will not including cygwin into MC just to break how NTFS work. This would also require MC to scan the filesystem twice. since the file information from cygwin is limited compared to what Windows has.



« Last Edit: May 10, 2021, 08:25:18 by Mathias (Author) »