1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing [] glob issue. fixes #621

This commit is contained in:
Patrik J. Braun 2023-10-08 22:32:32 +02:00
parent 43424526ee
commit e1ffeb0173
2 changed files with 8 additions and 6 deletions

View File

@ -161,7 +161,9 @@ export class CoverManager implements IObjectManager {
}); });
} else { } else {
q.orWhere('directory.path GLOB :path', { q.orWhere('directory.path GLOB :path', {
path: DiskMangerWorker.pathFromParent(dir) + '*', path: DiskMangerWorker.pathFromParent(dir)
// glob escaping. see https://github.com/bpatrik/pigallery2/issues/621
.replaceAll('[', '[[]') + '*',
}); });
} }
}) })

View File

@ -84,7 +84,7 @@ describe('CoverManager', (sqlHelper: DBTestHelper) => {
const setUpTestGallery = async (): Promise<void> => { const setUpTestGallery = async (): Promise<void> => {
const directory: ParentDirectoryDTO = TestHelper.getDirectoryEntry(); const directory: ParentDirectoryDTO = TestHelper.getDirectoryEntry(null, 'éűáúőóüöÉŰÚŐÓÜÖ[]^[[]]][asd]');
subDir = TestHelper.getDirectoryEntry(directory, 'The Phantom Menace'); subDir = TestHelper.getDirectoryEntry(directory, 'The Phantom Menace');
subDir2 = TestHelper.getDirectoryEntry(directory, 'Return of the Jedi'); subDir2 = TestHelper.getDirectoryEntry(directory, 'Return of the Jedi');
p = TestHelper.getPhotoEntry1(subDir); p = TestHelper.getPhotoEntry1(subDir);
@ -178,7 +178,7 @@ describe('CoverManager', (sqlHelper: DBTestHelper) => {
const conn = await SQLConnection.getConnection(); const conn = await SQLConnection.getConnection();
await conn.createQueryBuilder() await conn.createQueryBuilder()
.update(DirectoryEntity).set({validCover: false}).execute(); .update(DirectoryEntity).set({validCover: false}).execute();
expect(await pm.getPartialDirsWithoutCovers()).to.deep.equalInAnyOrder([dir, subDir, subDir2].map(d => partialDir(d))); expect(await pm.getPartialDirsWithoutCovers()).to.deep.equalInAnyOrder([dir, subDir, subDir2].map(d => partialDir(d)));
}); });
@ -279,13 +279,13 @@ describe('CoverManager', (sqlHelper: DBTestHelper) => {
expect(subdir.cover.id).to.equal(p2.id); expect(subdir.cover.id).to.equal(p2.id);
await conn.createQueryBuilder() await conn.createQueryBuilder()
.update(DirectoryEntity) .update(DirectoryEntity)
.set({validCover: false, cover: null}).execute(); .set({validCover: false, cover: null}).execute();
expect((await selectDir()).cover).to.equal(null); expect((await selectDir()).cover).to.equal(null);
const res = await gm.getParentDirFromId(conn, const res = await gm.getParentDirFromId(conn,
(await gm.getDirIdAndTime(conn, dir.name, dir.path)).id); (await gm.getDirIdAndTime(conn, dir.name, dir.path)).id);
subdir = await selectDir(); subdir = await selectDir();
expect(subdir.validCover).to.equal(true); expect(subdir.validCover).to.equal(true);
expect(subdir.cover.id).to.equal(p2.id); expect(subdir.cover.id).to.equal(p2.id);