Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The directory order of "sort by date - descending" is messed up after indexing the folders #751

Open
bruce30262 opened this issue Oct 22, 2023 · 5 comments

Comments

@bruce30262
Copy link
Contributor

Note: Please always try reproducing the issue on the :edge build. There is a chance that it was already fixed. If it's an UI issue, you can try reporducing it on the demo page.


Describe the bug
This issue happens when I was testing the release of V2.0.0 ( commit 4dc431f ). In the Gallery, if we set the sorting order to "By date - descending", the order of directory will be incorrect after indexing a folder.

To reproduce the issue:

  1. Create a folder called test under Gallery
  2. Prepare two folders in a tmp folder with the following structure:
> tree ./tmp
.
├── new
│   └── new_in
│       └── new.PNG # can be a random picture
└── old
    └── old_in
        └── old.PNG # can be a random picture
  1. Move the old folder into test folder, wait for 1 min
  2. Move the new folder into test folder
  3. Goto the Gallery page of test, set the sorting order to "By date - descending"
  4. Now inside the test gallery, the order of the folders should be correct ( new is in front of old, meaning new is newer ). Both folder have no cover since the folder is not indexed.
  5. Now click the new folder so the folder will be indexed.
  6. Go back to test Gallery and refresh the page. We'll notice that the new folder will be move behind the old folder, which is incorrect since the new folder should be the first folder in the gallery.

The above is just a simple example to demonstrate the issue. In my case ( a Gallery with lots of folder ), this issue messed up the order of lots of folder -- most of them will be "shifted" to the last order ( meaning pigallery2 think it's the oldest even though it's not ) after being indexed.

As for expected behavior: the order of the folders should follow the result of the ls -lt command. For example, if the result is:

new # latest
|
v
...
old # oldest

Then the order of the folders in Gallery should be:

new ->... old

Photo/video (optional) that causes the bug

N/A

Screenshots (optional)

N/A

Server logs (optional)

N/A

Environment (please complete the following information):

  • OS: Server runs on Linux, browser on Windows.
  • Browser: Brave

Used app version:
Using the docker image from here.
Version: V2.0.0
Commit: 4dc431f

@bpatrik
Copy link
Owner

bpatrik commented Oct 22, 2023 via email

@bruce30262
Copy link
Contributor Author

Do you have the same issue when you index folder?

Not sure what you mean by this, but I'll explain more what I tried :

When I reset a Gallery ( click "Gallery reset" ), the folders in the Gallery will be in correct order. Some of the folder doesn't have cover ( since they aren't index yet ). Then, I click the "Run now: Indexing" button in Settings page, after that, lots of folders are out of order ( many of them are being shifted backward even though they aren't that old ). Other observations:

  • Those being shifted to the wrong order are the one that didn't have cover before indexing. Other folders that have cover before indexing are still in the correct order.
  • If the whole gallery is not indexed, and I click a folder with no cover ( indexing it ), that folder will be move to the last order of the gallery ( meaning pigallery2 will think it's the oldest folder after indexing it, which is incorrect ).
  • Let's say we have the following order before indexing:
# newest -> oldest
# A, C, E have cover, B & D don't
A->B->C->D->E

After indexing, since B & D didn't have cover before indexing, they are wrongly move "backward" ( pigallery2 think they are older than E ), so the order will become:

A->C->E->D->B

# A, C, E are in correct order, D and B are wrong

Notice that B will be placed behind D. For some reason it will use "Descending name" to sort folders that are wrongly moved.


The directory sorting changed in the latest release but that assumes a
fully indexed directory or the sorting could be inconsistent.

I'm not sure what changed but I would say I prefer how pigallery2 handle directory sorting before V2.0.0. V1.9.5 works perfectly fine for me. Also I would prefer not fully index a Gallery since in my case it would take longer to load the page. It would be nice if we can bring back the sorting behavior in V1.9.5.

@bpatrik
Copy link
Owner

bpatrik commented Oct 22, 2023

Since b5dce0a, the app assumes that your gallery is fully indexed and uses that actual oldest photo data for sorting the folders. Previously it was using the last modification date of the folder.
If some folders are not indexed, it will fall back to the last modified date to that folder.

Do you have the same issue when you index folder?
Not sure what you mean by this, but I'll explain more what I tried :

I meant if the issue still exists if you fully index your gallery.

Adding a reference to dis discussion to the release notes.

@bpatrik
Copy link
Owner

bpatrik commented Oct 22, 2023

I'm happy to argue if this is the best approach, and don't mind improving it, but I think using the folder's oldest photo is better then the previous last modified date.

@bpatrik bpatrik added the bug label Oct 22, 2023
@bpatrik bpatrik added this to the Next (probably v2.5) milestone Oct 22, 2023
@bruce30262
Copy link
Contributor Author

Since b5dce0a, the app assumes that your gallery is fully indexed and uses that actual oldest photo data for sorting the folders. Previously it was using the last modification date of the folder.
If some folders are not indexed, it will fall back to the last modified date to that folder.

I see, thanks for the explanation. However it still confuses me since I found a folder, which is newly added that day ( new folder + new picture in it ), still being placed in older order after indexing even though it should be the newest folder in the gallery. Not sure why.

I'm happy to argue if this is the best approach, and don't mind improving it, but I think using the folder's oldest photo is better then the previous last modified date.

Hmmm to me the last modified date is more intuitive when thinking of "Descending date", I'm not used to remembering the oldest picture in the folder, can only remember which folder is modified last. It's probably because I use pigallery2 to host my comics and CG collections, so for me it's very important to track the folders by last modified date.

Is it possible to have both sorting methods in the application ? That way users can choose which "Descending date" sorting method they prefer to use when organizing their gallery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants