zanllp / sd-webui-infinite-image-browsing

A fast and powerful image/video browser for Stable Diffusion webui / ComfyUI / Fooocus / NovelAI / StableSwarmUI, featuring infinite scrolling and advanced search capabilities using image parameters. It also supports standalone operation.
MIT License
960 stars 119 forks source link

Deleting older images breaks date sorting in walk mode #705

Open silveroxides opened 1 month ago

silveroxides commented 1 month ago

In case it matters the OS is Windows 11 When deleting older images the entire rest of that folder gets pushed up as most recently updated. Shouldn't sorting be done based on file property and not folder? Because as you can see in screenshot, the files are still at their original date but the folder has been changed and thus I assume you are sorting based on folder property rather than file. Thing is. Technically you only need to getch property of the most recent file in a folder rather than only the folder to solve this.

image image

zanllp commented 1 month ago

It may be because you modified the default sorting method.

image
silveroxides commented 3 weeks ago

You don't seem to understand what I was trying to put forth in this issue. I am not trying to sort by created date. I am sorting by updated date. But the sorting for updated date is not based on file updated date but rather directory updated date. When a file inside a directory is deleted, the updated date for the directory is changed but not the updated date for the other containing files. When sorting is set to updated date it seems you are currently sorting files in walk mode in the order of directory updated date then file updated date with the directory taking priority? Is this correct? If this is correct I would suggest you inverse that priority so that it first and foremost sort based on files updated date rather than the directory properties updated date since the directory updated date is not inherited by the files.

example: we have 5(five) files inside 3(three) directories. Files have the following ID: A, B, C, D and E. Directories have the following ID: X, Y and Z. Last updated date is specified with semi-colon ; after an ID followed by date in the YYYY-MM-DD format (ex. Y;2024-02-16). Indented line signifies that file ID is a child of Directory ID. Current date in example is set to 2024-08-01(remember this). Initial structure and sort order(we only see files) based on updated:

X;2024-01-15
  A;2024-01-15
  B;2024-01-11
Y;2023-10-30
  C;2023-10-30
Z;2023-07-18
  D;2023-07-18
  E;2023-07-11
Viewed order in UI: A, B, C, D, E

As we can see all is sorted in order here. Now lets delete file D and based on the current sorting schema in infinite image browsing the following is now the order in which we see the files:

Z;2024-08-01
  E;2023-07-11
X;2024-01-15
  A;2024-01-15
  B;2024-01-11
Y;2023-10-30
  C;2023-10-30
Viewed order in UI: E, A, B, C

You might notice that even though file E was updated way back far before file A, B, C, we still see file E first even though that file has not been updated since 2023-01-15.

zanllp commented 3 weeks ago

You might want to try using the Fuzzy Search feature instead. It preprocesses the files into a database and then strictly sorts them by modification time . The current Walk mode implementation actually has significant benefits in many cases.

image

or

image image
silveroxides commented 2 weeks ago

I have been using this for months. I know about the fuzzy. But what I am saying is that it is basing modification time on directory and not files. If I delete one image that is 1 year old in a directory of 1000 images then they ALL gets pushed to top as the software thinks every file got modified. It basically breaks that sorting mode since you effectively cannot touch a single image without scrambling the sorting order

silveroxides commented 2 weeks ago

Here. Also datetime is not optimal for this. You are better of using time rather than datetime since you are doing comparison and not indexing cause that means you only need to compare floating point values for modified time rather than compare a string. The time module returns a Unix timestamp in floating point format.