You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we should change sorting by size to not need a preload of the filelist. there is no need to preload the filelist when we sort by mtime and we can use stat to get the size of the images much like we get the mtime. like so
diff --git a/src/filelist.c b/src/filelist.c
index 8da6e58..51331ce 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -466,7 +466,20 @@ int feh_cmp_pixels(void *file1, void *file2)
int feh_cmp_size(void *file1, void *file2)
{
- return((FEH_FILE(file1)->info->size - FEH_FILE(file2)->info->size));
+ struct stat s1, s2;
+
+ if (stat(FEH_FILE(file1)->filename, &s1)) {
+ feh_print_stat_error(FEH_FILE(file1)->filename);
+ return(-1);
+ }
+
+ if (stat(FEH_FILE(file2)->filename, &s2)) {
+ feh_print_stat_error(FEH_FILE(file2)->filename);
+ return(-1);
+ }
+
+ /* gib_list_sort is not stable, so explicitly return 0 as -1 */
+ return(s1.st_size < s2.st_size ? -1 : 1);
}
int feh_cmp_format(void *file1, void *file2)
diff --git a/src/filelist.h b/src/filelist.h
index 7f263dc..b4b8f98 100644
--- a/src/filelist.h
+++ b/src/filelist.h
@@ -71,11 +71,11 @@ enum sort_type {
SORT_NAME,
SORT_FILENAME,
SORT_DIRNAME,
- SORT_MTIME,
+ SORT_SIZE,
+ SORT_MTIME, // everything after SORT_MTIME requires a preload of the filelist
SORT_WIDTH,
SORT_HEIGHT,
SORT_PIXELS,
- SORT_SIZE,
SORT_FORMAT
};
Is there a reason we are not doing this. sorting by time does not modify the FEH_FILE struct and I think that this should sort the same.
The text was updated successfully, but these errors were encountered:
I think we should change sorting by size to not need a preload of the filelist. there is no need to preload the filelist when we sort by mtime and we can use stat to get the size of the images much like we get the mtime. like so
Is there a reason we are not doing this. sorting by time does not modify the FEH_FILE struct and I think that this should sort the same.
The text was updated successfully, but these errors were encountered: