Page 1 of 1

Is it okay to display the number of internal files on a folder

Posted: 16 Dec 2021, 23:58
by amwpsaa
Displays the number of files in the current folder on the thumbnail,Can it be done?

Re: Is it okay to display the number of internal files on a folder

Posted: 17 Dec 2021, 01:41
by mjau-mjau
amwpsaa wrote:Displays the number of files in the current folder on the thumbnail,Can it be done?
Yes it can be done, but I don't like the process. If we want to get "number of files" for all subfolders of current folder, we need to loop inside every subfolder with the PHP glob() command, just to count the files inside, which will be slow. Also, it's not compatible with folder-cache, because the cache for a folder can't know if the contents of a subfolder have been modified.

Actually, it might not be that slow, but cache needs to be disabled for this to work, so it will definitely be slower. There are other options: For example a button "load size" that loads file count and file size for all subfolders, but only when/if clicked, separately from the page load.

I will add it as an option, but it will slow down folder loading, and I can't figure out a practical way to make it work with cache. The option will be disabled by default.

Re: Is it okay to display the number of internal files on a folder

Posted: 17 Dec 2021, 12:08
by amwpsaa
mjau-mjau wrote:
17 Dec 2021, 01:41

Yes it can be done, but I don't like the process. If we want to get "number of files" for all subfolders of current folder, we need to loop inside every subfolder with the PHP glob() command, just to count the files inside, which will be slow.
I don't think it's necessary to calculate all the subfolders, that's definitely slow

Re: Is it okay to display the number of internal files on a folder

Posted: 17 Dec 2021, 23:12
by mjau-mjau
amwpsaa wrote:I don't think it's necessary to calculate all the subfolders, that's definitely slow
But that's the only way to get the "file count" for all subfolders of current folder. We need to php glob() into all sub-folders and count the files that are returned. It's not gonna be too slow, but it would depend on the amount of subfolders and amount of files inside all subfolders, and also the speed of the server.

There might be other options, but I need to think about technical implementation.