mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Improving saved search pg2conf tests
This commit is contained in:
parent
b126022454
commit
30c2497f8f
@ -173,8 +173,7 @@ export class AuthenticationMWs {
|
|||||||
return next();
|
return next();
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
return next(new ErrorDTO(ErrorCodes.CREDENTIAL_NOT_FOUND, 'credentials not found during login', err));
|
||||||
return next(new ErrorDTO(ErrorCodes.CREDENTIAL_NOT_FOUND, 'credentials not found during login'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ export class IndexingManager implements IIndexingManager {
|
|||||||
if (ServerPG2ConfMap[f.name] === ServerSidePG2ConfAction.SAVED_SEARCH) {
|
if (ServerPG2ConfMap[f.name] === ServerSidePG2ConfAction.SAVED_SEARCH) {
|
||||||
const fullMediaPath = path.join(ProjectPath.ImageFolder, f.directory.path, f.directory.name, f.name);
|
const fullMediaPath = path.join(ProjectPath.ImageFolder, f.directory.path, f.directory.name, f.name);
|
||||||
|
|
||||||
Logger.silly(LOG_TAG, 'Saving saved searches to DB from:', fullMediaPath);
|
Logger.silly(LOG_TAG, 'Saving saved-searches to DB from:', fullMediaPath);
|
||||||
const savedSearches: { name: string, searchQuery: SearchQueryDTO }[] =
|
const savedSearches: { name: string, searchQuery: SearchQueryDTO }[] =
|
||||||
JSON.parse(await fs.promises.readFile(fullMediaPath, 'utf8'));
|
JSON.parse(await fs.promises.readFile(fullMediaPath, 'utf8'));
|
||||||
for (const s of savedSearches) {
|
for (const s of savedSearches) {
|
||||||
@ -363,7 +363,7 @@ export class IndexingManager implements IIndexingManager {
|
|||||||
this.isSaving = true;
|
this.isSaving = true;
|
||||||
try {
|
try {
|
||||||
const connection = await SQLConnection.getConnection();
|
const connection = await SQLConnection.getConnection();
|
||||||
const serverSideConfigs = scannedDirectory.metaFile.filter(m => ServerPG2ConfMap[m.name]);
|
const serverSideConfigs = scannedDirectory.metaFile.filter(m => !!ServerPG2ConfMap[m.name]);
|
||||||
scannedDirectory.metaFile = scannedDirectory.metaFile.filter(m => !ServerPG2ConfMap[m.name]);
|
scannedDirectory.metaFile = scannedDirectory.metaFile.filter(m => !ServerPG2ConfMap[m.name]);
|
||||||
const currentDirId: number = await this.saveParentDir(connection, scannedDirectory);
|
const currentDirId: number = await this.saveParentDir(connection, scannedDirectory);
|
||||||
await this.saveChildDirs(connection, currentDirId, scannedDirectory);
|
await this.saveChildDirs(connection, currentDirId, scannedDirectory);
|
||||||
@ -372,8 +372,6 @@ export class IndexingManager implements IIndexingManager {
|
|||||||
await ObjectManagers.getInstance().PersonManager.onGalleryIndexUpdate();
|
await ObjectManagers.getInstance().PersonManager.onGalleryIndexUpdate();
|
||||||
await ObjectManagers.getInstance().VersionManager.updateDataVersion();
|
await ObjectManagers.getInstance().VersionManager.updateDataVersion();
|
||||||
await IndexingManager.processServerSidePG2Conf(serverSideConfigs);
|
await IndexingManager.processServerSidePG2Conf(serverSideConfigs);
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
} finally {
|
||||||
this.isSaving = false;
|
this.isSaving = false;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ export const PG2ConfMap = {
|
|||||||
|
|
||||||
|
|
||||||
export enum ServerSidePG2ConfAction {
|
export enum ServerSidePG2ConfAction {
|
||||||
|
// Enum always starts from 1 as !!0 === false
|
||||||
SAVED_SEARCH = 1
|
SAVED_SEARCH = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,15 +583,18 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
|||||||
|
|
||||||
it('.saved_searches.pg2conf', async () => {
|
it('.saved_searches.pg2conf', async () => {
|
||||||
Config.Server.Threading.enabled = false;
|
Config.Server.Threading.enabled = false;
|
||||||
|
Config.Client.Album.enabled = true;
|
||||||
|
|
||||||
Config.Server.Media.folder = path.join(__dirname, '/../../../assets');
|
Config.Server.Media.folder = path.join(__dirname, '/../../../assets');
|
||||||
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
||||||
const im = new IndexingManagerTest();
|
const im = new IndexingManagerTest();
|
||||||
const am = new AlbumManager();
|
const am = new AlbumManager();
|
||||||
|
|
||||||
const dir = await DiskManager.scanDirectory('/');
|
const dir = await DiskManager.scanDirectory('/');
|
||||||
await im.saveToDB(dir);
|
await im.saveToDB(dir);
|
||||||
|
|
||||||
const albums = await am.getAlbums();
|
const albums = await am.getAlbums();
|
||||||
expect(albums[0].preview).to.be.an('object');
|
// expect(albums[0].preview).to.be.an('object');
|
||||||
delete albums[0].preview;
|
delete albums[0].preview;
|
||||||
expect(albums).to.be.equalInAnyOrder([
|
expect(albums).to.be.equalInAnyOrder([
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user