Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
amwpsaa
Experienced
Topic Author
Posts: 53
Joined: 29 Jul 2021, 08:46

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

16 Dec 2021, 23:58

Displays the number of files in the current folder on the thumbnail,Can it be done?
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

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

17 Dec 2021, 01:41

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.
 
User avatar
amwpsaa
Experienced
Topic Author
Posts: 53
Joined: 29 Jul 2021, 08:46

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

17 Dec 2021, 12:08

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
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

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

17 Dec 2021, 23:12

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.