From 42fd161a66e5ccb1c407c4ebafce3de7f8b24d54 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 6 Feb 2022 11:36:45 +0100 Subject: [PATCH] Making preview manager to first find photo in the same directory then in any subdirectories without any ordering between subdirectories. --- src/backend/model/database/sql/PreviewManager.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/backend/model/database/sql/PreviewManager.ts b/src/backend/model/database/sql/PreviewManager.ts index fc19a9d3..fa3f09e7 100644 --- a/src/backend/model/database/sql/PreviewManager.ts +++ b/src/backend/model/database/sql/PreviewManager.ts @@ -160,11 +160,9 @@ export class PreviewManager implements IPreviewManager { }); } })); - if (Config.Server.Database.type === DatabaseType.mysql) { - query.orderBy('CHAR_LENGTH(directory.path)', 'ASC'); // shorter the path, its higher up in the hierarchy - } else { - query.orderBy('LENGTH(directory.path)', 'ASC'); // shorter the path, its higher up in the hierarchy - } + // Select from the directory if any otherwise from any subdirectories. + // (There is no priority between subdirectories) + query.orderBy(`CASE WHEN directory.id = ${dir.id} THEN 0 ELSE 1 END`, 'ASC'); PreviewManager.setSorting(query);