mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Fixing face caching issue
This commit is contained in:
parent
d0a464b526
commit
872e63703d
@ -42,7 +42,7 @@ export class ThumbnailGeneratorMWs {
|
|||||||
|
|
||||||
|
|
||||||
// tslint:disable-next-line:typedef
|
// tslint:disable-next-line:typedef
|
||||||
public static addThumbnailInfoForPersons(req: Request, res: Response, next: NextFunction): any {
|
public static addThumbnailInfoForPersons(req: Request, res: Response, next: NextFunction): void {
|
||||||
if (!req.resultPipe) {
|
if (!req.resultPipe) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
@ -51,7 +51,11 @@ export class ThumbnailGeneratorMWs {
|
|||||||
const size: number = Config.Client.Media.Thumbnail.personThumbnailSize;
|
const size: number = Config.Client.Media.Thumbnail.personThumbnailSize;
|
||||||
|
|
||||||
const persons: PersonWithSampleRegion[] = req.resultPipe;
|
const persons: PersonWithSampleRegion[] = req.resultPipe;
|
||||||
|
|
||||||
for (const item of persons) {
|
for (const item of persons) {
|
||||||
|
if (!item.sampleRegion) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// load parameters
|
// load parameters
|
||||||
const mediaPath = path.join(ProjectPath.ImageFolder,
|
const mediaPath = path.join(ProjectPath.ImageFolder,
|
||||||
item.sampleRegion.media.directory.path,
|
item.sampleRegion.media.directory.path,
|
||||||
|
@ -77,10 +77,8 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
|||||||
// on the fly reindexing
|
// on the fly reindexing
|
||||||
|
|
||||||
Logger.silly(LOG_TAG, 'lazy reindexing reason: cache timeout: lastScanned: '
|
Logger.silly(LOG_TAG, 'lazy reindexing reason: cache timeout: lastScanned: '
|
||||||
+ (Date.now() - dir.lastScanned) + ' ms ago, cachedFolderTimeout:' + Config.Server.Indexing.cachedFolderTimeout);
|
+ (Date.now() - dir.lastScanned) + 'ms ago, cachedFolderTimeout:' + Config.Server.Indexing.cachedFolderTimeout);
|
||||||
ObjectManagers.getInstance().IndexingManager.indexDirectory(relativeDirectoryName).catch((err): void => {
|
ObjectManagers.getInstance().IndexingManager.indexDirectory(relativeDirectoryName).catch(console.error);
|
||||||
console.error(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
await this.fillParentDir(connection, dir);
|
await this.fillParentDir(connection, dir);
|
||||||
return dir;
|
return dir;
|
||||||
|
@ -30,17 +30,6 @@ export class PersonManager implements ISQLPersonManager {
|
|||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async loadAll(): Promise<void> {
|
|
||||||
const connection = await SQLConnection.getConnection();
|
|
||||||
const personRepository = connection.getRepository(PersonEntry);
|
|
||||||
this.persons = await personRepository.find({
|
|
||||||
relations: ['sampleRegion',
|
|
||||||
'sampleRegion.media',
|
|
||||||
'sampleRegion.media.directory']
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getAll(): Promise<PersonEntry[]> {
|
public async getAll(): Promise<PersonEntry[]> {
|
||||||
if (this.persons === null) {
|
if (this.persons === null) {
|
||||||
await this.loadAll();
|
await this.loadAll();
|
||||||
@ -48,7 +37,6 @@ export class PersonManager implements ISQLPersonManager {
|
|||||||
return this.persons;
|
return this.persons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for statistic
|
* Used for statistic
|
||||||
*/
|
*/
|
||||||
@ -66,7 +54,6 @@ export class PersonManager implements ISQLPersonManager {
|
|||||||
return this.persons.find((p): boolean => p.name === name);
|
return this.persons.find((p): boolean => p.name === name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async saveAll(names: string[]): Promise<void> {
|
public async saveAll(names: string[]): Promise<void> {
|
||||||
const toSave: { name: string }[] = [];
|
const toSave: { name: string }[] = [];
|
||||||
const connection = await SQLConnection.getConnection();
|
const connection = await SQLConnection.getConnection();
|
||||||
@ -90,12 +77,21 @@ export class PersonManager implements ISQLPersonManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async onGalleryIndexUpdate(): Promise<void> {
|
public async onGalleryIndexUpdate(): Promise<void> {
|
||||||
await this.updateCounts();
|
await this.updateCounts();
|
||||||
await this.updateSamplePhotos();
|
await this.updateSamplePhotos();
|
||||||
|
await this.loadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async loadAll(): Promise<void> {
|
||||||
|
const connection = await SQLConnection.getConnection();
|
||||||
|
const personRepository = connection.getRepository(PersonEntry);
|
||||||
|
this.persons = await personRepository.find({
|
||||||
|
relations: ['sampleRegion',
|
||||||
|
'sampleRegion.media',
|
||||||
|
'sampleRegion.media.directory']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private async updateCounts(): Promise<void> {
|
private async updateCounts(): Promise<void> {
|
||||||
const connection = await SQLConnection.getConnection();
|
const connection = await SQLConnection.getConnection();
|
||||||
|
Loading…
Reference in New Issue
Block a user