When synchronization running a new directories/albums are learnt from filesystem by get_fs_directories function in admin/include/functions.php. It use readdir PHP function without any type of sorting. I tested it for some time and order of this dirs is pretty mysterious. My tests was based on three directories (rok_01, rok_02, rok_03) and some experiments with mtimes, ctimes, inode numbers of directories and files. In all my tests i had rok_02 before rok_01. Don't know why, but i figured out how to do it better.
I changed get_fs_directories function to use glob PHP function instead of opendir/readdir/closedir. There is also usort, which sorts new categories by mtime (modify time) of corresponding directories.
Tested dot (hidden) directories and performance too. Speed is roughly the same (about 80 milliseconds for my 500 albums).
I think this is more logical and also very useful when importing a huge number of albums. For example i plan to change mtime of every dir based on information from Gallery2 SQL table so with some luck i will have the same album order like in original gallery.
**Reported by jc on 1 Feb 2015 16:42**
**Version:** 2.7.3
When synchronization running a new directories/albums are learnt from filesystem by get_fs_directories function in admin/include/functions.php. It use readdir PHP function without any type of sorting. I tested it for some time and order of this dirs is pretty mysterious. My tests was based on three directories (rok_01, rok_02, rok_03) and some experiments with mtimes, ctimes, inode numbers of directories and files. In all my tests i had rok_02 before rok_01. Don't know why, but i figured out how to do it better.
I changed get_fs_directories function to use glob PHP function instead of opendir/readdir/closedir. There is also usort, which sorts new categories by mtime (modify time) of corresponding directories.
Tested dot (hidden) directories and performance too. Speed is roughly the same (about 80 milliseconds for my 500 albums).
I think this is more logical and also very useful when importing a huge number of albums. For example i plan to change mtime of every dir based on information from Gallery2 SQL table so with some luck i will have the same album order like in original gallery.
Full function code attached and pasted to http://pastebin.com/TaPvryyh too.
[Piwigo Bugtracker #3194](http://piwigo.org/bugs/view.php?id=3194)
<!-- github-sync-id:97227026 -->
Are there any news on this?
After every synchronization new albums are added in the wrong order (I use Z->A ordering)...
... can I help with this?
Are there any news on this?
After every synchronization new albums are added in the wrong order (I use Z->A ordering)...
... can I help with this?
<!-- github-comment-id:425410062 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Reported by jc on 1 Feb 2015 16:42
Version: 2.7.3
When synchronization running a new directories/albums are learnt from filesystem by get_fs_directories function in admin/include/functions.php. It use readdir PHP function without any type of sorting. I tested it for some time and order of this dirs is pretty mysterious. My tests was based on three directories (rok_01, rok_02, rok_03) and some experiments with mtimes, ctimes, inode numbers of directories and files. In all my tests i had rok_02 before rok_01. Don't know why, but i figured out how to do it better.
I changed get_fs_directories function to use glob PHP function instead of opendir/readdir/closedir. There is also usort, which sorts new categories by mtime (modify time) of corresponding directories.
Tested dot (hidden) directories and performance too. Speed is roughly the same (about 80 milliseconds for my 500 albums).
I think this is more logical and also very useful when importing a huge number of albums. For example i plan to change mtime of every dir based on information from Gallery2 SQL table so with some luck i will have the same album order like in original gallery.
Full function code attached and pasted to http://pastebin.com/TaPvryyh too.
Piwigo Bugtracker #3194
Are there any news on this?
After every synchronization new albums are added in the wrong order (I use Z->A ordering)...
... can I help with this?