mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-08 04:03:48 +02:00
remove threading #641
This commit is contained in:
parent
4dc431fe22
commit
2b0d1a96a6
@ -1,6 +1,6 @@
|
||||
import {Config} from '../src/common/config/private/Config';
|
||||
import {ObjectManagers} from '../src/backend/model/ObjectManagers';
|
||||
import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
|
||||
import {DiskManager} from '../src/backend/model/fileaccess/DiskManager';
|
||||
import {IndexingManager} from '../src/backend/model/database/IndexingManager';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
@ -84,7 +84,7 @@ export class BenchmarkRunner {
|
||||
}
|
||||
|
||||
async bmSaveDirectory(): Promise<BenchmarkResult[]> {
|
||||
const dir = await DiskMangerWorker.scanDirectory(this.biggestDirPath);
|
||||
const dir = await DiskManager.scanDirectory(this.biggestDirPath);
|
||||
const bm = new Benchmark('Saving directory to DB', null,
|
||||
(): Promise<void> => this.resetDB(), null,
|
||||
async (): Promise<void> => {
|
||||
@ -110,7 +110,7 @@ export class BenchmarkRunner {
|
||||
});
|
||||
bm.addAStep({
|
||||
name: 'Scanning directory',
|
||||
fn: async (): Promise<ContentWrapper> => new ContentWrapper(await DiskMangerWorker.scanDirectory(this.biggestDirPath))
|
||||
fn: async (): Promise<ContentWrapper> => new ContentWrapper(await DiskManager.scanDirectory(this.biggestDirPath))
|
||||
});
|
||||
return await bm.run(this.RUNS);
|
||||
}
|
||||
@ -285,7 +285,6 @@ export class BenchmarkRunner {
|
||||
|
||||
|
||||
private resetDB = async (): Promise<void> => {
|
||||
Config.Server.Threading.enabled = false;
|
||||
await ObjectManagers.reset();
|
||||
await fs.promises.rm(ProjectPath.DBFolder, {recursive: true, force: true});
|
||||
Config.Database.type = DatabaseType.sqlite;
|
||||
@ -294,7 +293,6 @@ export class BenchmarkRunner {
|
||||
};
|
||||
|
||||
private async setupDB(): Promise<void> {
|
||||
Config.Server.Threading.enabled = false;
|
||||
await this.resetDB();
|
||||
await new Promise<void>((resolve, reject): void => {
|
||||
try {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import * as cluster from 'cluster';
|
||||
import {Server} from './server';
|
||||
import {Worker} from './model/threading/Worker';
|
||||
import {ConfigDiagnostics} from './model/diagnostics/ConfigDiagnostics';
|
||||
|
||||
|
||||
@ -13,9 +11,5 @@ if ((process.argv || []).includes('--run-diagnostics')) {
|
||||
process.exit(0);
|
||||
});
|
||||
} else {
|
||||
if ((cluster as any).isMaster) {
|
||||
new Server();
|
||||
} else {
|
||||
Worker.process();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import {Config} from '../../common/config/private/Config';
|
||||
import {UserDTOUtils} from '../../common/entities/UserDTO';
|
||||
import {MediaDTO, MediaDTOUtils} from '../../common/entities/MediaDTO';
|
||||
import {QueryParams} from '../../common/QueryParams';
|
||||
import {VideoProcessing} from '../model/fileprocessing/VideoProcessing';
|
||||
import {VideoProcessing} from '../model/fileaccess/fileprocessing/VideoProcessing';
|
||||
import {SearchQueryDTO, SearchQueryTypes,} from '../../common/entities/SearchQueryDTO';
|
||||
import {LocationLookupException} from '../exceptions/LocationLookupException';
|
||||
import {SupportedFormats} from '../../common/SupportedFormats';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {NextFunction, Request, Response} from 'express';
|
||||
import * as fs from 'fs';
|
||||
import {Config} from '../../common/config/private/Config';
|
||||
import {GPXProcessing} from '../model/fileprocessing/GPXProcessing';
|
||||
import {GPXProcessing} from '../model/fileaccess/fileprocessing/GPXProcessing';
|
||||
import {Logger} from '../Logger';
|
||||
|
||||
const LOG_TAG = 'MetaFileMWs';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {NextFunction, Request, Response} from 'express';
|
||||
import * as fs from 'fs';
|
||||
import {PhotoProcessing} from '../../model/fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from '../../model/fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
||||
|
||||
|
@ -6,9 +6,9 @@ import {ContentWrapper} from '../../../common/entities/ConentWrapper';
|
||||
import {DirectoryPathDTO, ParentDirectoryDTO, SubDirectoryDTO,} from '../../../common/entities/DirectoryDTO';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {ThumbnailSourceType} from '../../model/threading/PhotoWorker';
|
||||
import {ThumbnailSourceType} from '../../model/fileaccess/PhotoWorker';
|
||||
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {PhotoProcessing} from '../../model/fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from '../../model/fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {ServerTime} from '../ServerTimingMWs';
|
||||
import {PersonEntry} from '../../model/database/enitites/PersonEntry';
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
import {ParentDirectoryDTO,} from '../../common/entities/DirectoryDTO';
|
||||
import {Logger} from '../Logger';
|
||||
import {Config} from '../../common/config/private/Config';
|
||||
import {DiskManagerTH} from './threading/ThreadPool';
|
||||
import {DirectoryScanSettings, DiskMangerWorker,} from './threading/DiskMangerWorker';
|
||||
import {FileDTO} from '../../common/entities/FileDTO';
|
||||
|
||||
const LOG_TAG = '[DiskManager]';
|
||||
|
||||
export class DiskManager {
|
||||
static threadPool: DiskManagerTH = null;
|
||||
|
||||
public static init(): void {
|
||||
if (Config.Server.Threading.enabled === true) {
|
||||
DiskManager.threadPool = new DiskManagerTH(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List all files in a folder as fast as possible
|
||||
*/
|
||||
public static async scanDirectoryNoMetadata(
|
||||
relativeDirectoryName: string,
|
||||
settings: DirectoryScanSettings = {}
|
||||
): Promise<ParentDirectoryDTO<FileDTO>> {
|
||||
settings.noMetadata = true;
|
||||
return this.scanDirectory(relativeDirectoryName, settings);
|
||||
}
|
||||
|
||||
public static async scanDirectory(
|
||||
relativeDirectoryName: string,
|
||||
settings: DirectoryScanSettings = {}
|
||||
): Promise<ParentDirectoryDTO> {
|
||||
Logger.silly(LOG_TAG, 'scanning directory:', relativeDirectoryName);
|
||||
|
||||
let directory: ParentDirectoryDTO;
|
||||
|
||||
if (Config.Server.Threading.enabled === true) {
|
||||
directory = await DiskManager.threadPool.execute(
|
||||
relativeDirectoryName,
|
||||
settings
|
||||
);
|
||||
} else {
|
||||
directory = (await DiskMangerWorker.scanDirectory(
|
||||
relativeDirectoryName,
|
||||
settings
|
||||
)) as ParentDirectoryDTO;
|
||||
}
|
||||
return directory;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {Brackets, SelectQueryBuilder, WhereExpression} from 'typeorm';
|
||||
import {MediaEntity} from './enitites/MediaEntity';
|
||||
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
||||
import {DiskManager} from '../fileaccess/DiskManager';
|
||||
import {ObjectManagers} from '../ObjectManagers';
|
||||
import {DatabaseType} from '../../../common/config/private/PrivateConfig';
|
||||
import {SQLConnection} from './SQLConnection';
|
||||
@ -37,7 +37,7 @@ export class CoverManager implements IObjectManager {
|
||||
|
||||
public async onNewDataVersion(changedDir: ParentDirectoryDTO): Promise<void> {
|
||||
// Invalidating Album cover
|
||||
let fullPath = DiskMangerWorker.normalizeDirPath(
|
||||
let fullPath = DiskManager.normalizeDirPath(
|
||||
path.join(changedDir.path, changedDir.name)
|
||||
);
|
||||
const query = (await SQLConnection.getConnection())
|
||||
@ -46,10 +46,10 @@ export class CoverManager implements IObjectManager {
|
||||
.set({validCover: false});
|
||||
|
||||
let i = 0;
|
||||
const root = DiskMangerWorker.pathFromRelativeDirName('.');
|
||||
const root = DiskManager.pathFromRelativeDirName('.');
|
||||
while (fullPath !== root) {
|
||||
const name = DiskMangerWorker.dirName(fullPath);
|
||||
const parentPath = DiskMangerWorker.pathFromRelativeDirName(fullPath);
|
||||
const name = DiskManager.dirName(fullPath);
|
||||
const parentPath = DiskManager.pathFromRelativeDirName(fullPath);
|
||||
fullPath = parentPath;
|
||||
++i;
|
||||
query.orWhere(
|
||||
@ -67,8 +67,8 @@ export class CoverManager implements IObjectManager {
|
||||
query.orWhere(
|
||||
new Brackets((q: WhereExpression) => {
|
||||
const param: { [key: string]: string } = {};
|
||||
param['name' + i] = DiskMangerWorker.dirName('.');
|
||||
param['path' + i] = DiskMangerWorker.pathFromRelativeDirName('.');
|
||||
param['name' + i] = DiskManager.dirName('.');
|
||||
param['path' + i] = DiskManager.pathFromRelativeDirName('.');
|
||||
q.where(`path = :path${i}`, param);
|
||||
q.andWhere(`name = :name${i}`, param);
|
||||
})
|
||||
@ -157,11 +157,11 @@ export class CoverManager implements IObjectManager {
|
||||
});
|
||||
if (Config.Database.type === DatabaseType.mysql) {
|
||||
q.orWhere('directory.path like :path || \'%\'', {
|
||||
path: DiskMangerWorker.pathFromParent(dir),
|
||||
path: DiskManager.pathFromParent(dir),
|
||||
});
|
||||
} else {
|
||||
q.orWhere('directory.path GLOB :path', {
|
||||
path: DiskMangerWorker.pathFromParent(dir)
|
||||
path: DiskManager.pathFromParent(dir)
|
||||
// glob escaping. see https://github.com/bpatrik/pigallery2/issues/621
|
||||
.replaceAll('[', '[[]') + '*',
|
||||
});
|
||||
|
@ -9,11 +9,11 @@ import {Config} from '../../../common/config/private/Config';
|
||||
import {Connection} from 'typeorm';
|
||||
import {MediaEntity} from './enitites/MediaEntity';
|
||||
import {VideoEntity} from './enitites/VideoEntity';
|
||||
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
||||
import {Logger} from '../../Logger';
|
||||
import {ObjectManagers} from '../ObjectManagers';
|
||||
import {DuplicatesDTO} from '../../../common/entities/DuplicatesDTO';
|
||||
import {ReIndexingSensitivity} from '../../../common/config/private/PrivateConfig';
|
||||
import { DiskManager } from '../fileaccess/DiskManager';
|
||||
|
||||
const LOG_TAG = '[GalleryManager]';
|
||||
|
||||
@ -22,7 +22,7 @@ export class GalleryManager {
|
||||
name: string;
|
||||
parent: string;
|
||||
} {
|
||||
relativeDirectoryName = DiskMangerWorker.normalizeDirPath(
|
||||
relativeDirectoryName = DiskManager.normalizeDirPath(
|
||||
relativeDirectoryName
|
||||
);
|
||||
return {
|
||||
@ -57,7 +57,7 @@ export class GalleryManager {
|
||||
const stat = fs.statSync(
|
||||
path.join(ProjectPath.ImageFolder, relativeDirectoryName)
|
||||
);
|
||||
const lastModified = DiskMangerWorker.calcLastModified(stat);
|
||||
const lastModified = DiskManager.calcLastModified(stat);
|
||||
|
||||
// If it seems that the content did not change, do not work on it
|
||||
if (
|
||||
|
@ -1,7 +1,6 @@
|
||||
import {DirectoryBaseDTO, DirectoryDTOUtils, DirectoryPathDTO, ParentDirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
||||
import {DirectoryEntity} from './enitites/DirectoryEntity';
|
||||
import {SQLConnection} from './SQLConnection';
|
||||
import {DiskManager} from '../DiskManger';
|
||||
import {PhotoEntity, PhotoMetadataEntity} from './enitites/PhotoEntity';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
import {PhotoMetadata,} from '../../../common/entities/PhotoDTO';
|
||||
@ -13,7 +12,6 @@ import {FileEntity} from './enitites/FileEntity';
|
||||
import {FileDTO} from '../../../common/entities/FileDTO';
|
||||
import {NotificationManager} from '../NotifocationManager';
|
||||
import {ObjectManagers} from '../ObjectManagers';
|
||||
import {DiskMangerWorker} from '../threading/DiskMangerWorker';
|
||||
import {Logger} from '../../Logger';
|
||||
import {ServerPG2ConfMap, ServerSidePG2ConfAction,} from '../../../common/PG2ConfMap';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
@ -24,6 +22,7 @@ import {PersonEntry} from './enitites/PersonEntry';
|
||||
import {PersonJunctionTable} from './enitites/PersonJunctionTable';
|
||||
import {MDFileEntity} from './enitites/MDFileEntity';
|
||||
import {MDFileDTO} from '../../../common/entities/MDFileDTO';
|
||||
import {DiskManager} from '../fileaccess/DiskManager';
|
||||
|
||||
const LOG_TAG = '[IndexingManager]';
|
||||
|
||||
@ -242,9 +241,9 @@ export class IndexingManager {
|
||||
.update(DirectoryEntity)
|
||||
.set({parent: currentDirId as unknown})
|
||||
.where('path = :path', {
|
||||
path: DiskMangerWorker.pathFromParent(scannedDirectory),
|
||||
path: DiskManager.pathFromParent(scannedDirectory),
|
||||
})
|
||||
.andWhere('name NOT LIKE :root', {root: DiskMangerWorker.dirName('.')})
|
||||
.andWhere('name NOT LIKE :root', {root: DiskManager.dirName('.')})
|
||||
.andWhere('parent IS NULL')
|
||||
.execute();
|
||||
|
||||
|
@ -6,15 +6,18 @@ import {ProjectPath} from '../../ProjectPath';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {VideoDTO} from '../../../common/entities/VideoDTO';
|
||||
import {FileDTO} from '../../../common/entities/FileDTO';
|
||||
import {MetadataLoader} from './MetadataLoader';
|
||||
import {Logger} from '../../Logger';
|
||||
import {VideoProcessing} from '../fileprocessing/VideoProcessing';
|
||||
import {PhotoProcessing} from '../fileprocessing/PhotoProcessing';
|
||||
import {VideoProcessing} from './fileprocessing/VideoProcessing';
|
||||
import {PhotoProcessing} from './fileprocessing/PhotoProcessing';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
import {GPXProcessing} from '../fileprocessing/GPXProcessing';
|
||||
import {GPXProcessing} from './fileprocessing/GPXProcessing';
|
||||
import {MDFileDTO} from '../../../common/entities/MDFileDTO';
|
||||
import {MetadataLoader} from './MetadataLoader';
|
||||
|
||||
export class DiskMangerWorker {
|
||||
|
||||
const LOG_TAG = '[DiskManager]';
|
||||
|
||||
export class DiskManager {
|
||||
public static calcLastModified(stat: Stats): number {
|
||||
return Math.max(stat.ctime.getTime(), stat.mtime.getTime());
|
||||
}
|
||||
@ -101,8 +104,9 @@ export class DiskMangerWorker {
|
||||
relativeDirectoryName: string,
|
||||
settings: DirectoryScanSettings = {}
|
||||
): Promise<ParentDirectoryDTO> {
|
||||
Logger.silly(LOG_TAG, 'scanning directory:', relativeDirectoryName);
|
||||
relativeDirectoryName = this.normalizeDirPath(relativeDirectoryName);
|
||||
const directoryName = DiskMangerWorker.dirName(relativeDirectoryName);
|
||||
const directoryName = DiskManager.dirName(relativeDirectoryName);
|
||||
const directoryParent = this.pathFromRelativeDirName(relativeDirectoryName);
|
||||
const absoluteDirectoryName = path.join(
|
||||
ProjectPath.ImageFolder,
|
||||
@ -147,7 +151,7 @@ export class DiskMangerWorker {
|
||||
if (
|
||||
settings.noDirectory === true ||
|
||||
settings.coverOnly === true ||
|
||||
(await DiskMangerWorker.excludeDir(
|
||||
(await DiskManager.excludeDir(
|
||||
file,
|
||||
relativeDirectoryName,
|
||||
absoluteDirectoryName
|
||||
@ -157,7 +161,7 @@ export class DiskMangerWorker {
|
||||
}
|
||||
|
||||
// create cover directory
|
||||
const d = (await DiskMangerWorker.scanDirectory(
|
||||
const d = (await DiskManager.scanDirectory(
|
||||
path.join(relativeDirectoryName, file),
|
||||
{
|
||||
coverOnly: true,
|
||||
@ -222,7 +226,7 @@ export class DiskMangerWorker {
|
||||
}
|
||||
} else if (GPXProcessing.isMetaFile(fullFilePath)) {
|
||||
if (
|
||||
!DiskMangerWorker.isEnabledMetaFile(fullFilePath) ||
|
||||
!DiskManager.isEnabledMetaFile(fullFilePath) ||
|
||||
settings.noMetaFile === true ||
|
||||
settings.coverOnly === true
|
||||
) {
|
||||
@ -248,7 +252,7 @@ export class DiskMangerWorker {
|
||||
);
|
||||
|
||||
directory.metaFile.forEach(mf => {
|
||||
if (DiskMangerWorker.isMarkdown(mf.name)) {
|
||||
if (DiskManager.isMarkdown(mf.name)) {
|
||||
(mf as MDFileDTO).date = directory.youngestMedia;
|
||||
}
|
||||
});
|
@ -1,9 +1,9 @@
|
||||
import * as path from 'path';
|
||||
import {constants as fsConstants, promises as fsp} from 'fs';
|
||||
import * as xml2js from 'xml2js';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {SupportedFormats} from '../../../common/SupportedFormats';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {SupportedFormats} from '../../../../common/SupportedFormats';
|
||||
|
||||
type gpxEntry = { '$': { lat: string, lon: string }, ele?: string[], time?: string[], extensions?: unknown };
|
||||
|
@ -2,14 +2,14 @@ import * as path from 'path';
|
||||
import {constants as fsConstants, promises as fsp} from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as crypto from 'crypto';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {MediaRendererInput, PhotoWorker, SvgRendererInput, ThumbnailSourceType,} from '../threading/PhotoWorker';
|
||||
import {ITaskExecuter, TaskExecuter} from '../threading/TaskExecuter';
|
||||
import {FaceRegion, PhotoDTO} from '../../../common/entities/PhotoDTO';
|
||||
import {SupportedFormats} from '../../../common/SupportedFormats';
|
||||
import {PersonEntry} from '../database/enitites/PersonEntry';
|
||||
import {SVGIconConfig} from '../../../common/config/public/ClientConfig';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {MediaRendererInput, PhotoWorker, SvgRendererInput, ThumbnailSourceType,} from '../PhotoWorker';
|
||||
import {ITaskExecuter, TaskExecuter} from '../TaskExecuter';
|
||||
import {FaceRegion, PhotoDTO} from '../../../../common/entities/PhotoDTO';
|
||||
import {SupportedFormats} from '../../../../common/SupportedFormats';
|
||||
import {PersonEntry} from '../../database/enitites/PersonEntry';
|
||||
import {SVGIconConfig} from '../../../../common/config/public/ClientConfig';
|
||||
|
||||
export class PhotoProcessing {
|
||||
private static initDone = false;
|
||||
@ -21,19 +21,10 @@ export class PhotoProcessing {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.Server.Threading.enabled === true) {
|
||||
if (Config.Server.Threading.thumbnailThreads > 0) {
|
||||
Config.Media.Thumbnail.concurrentThumbnailGenerations =
|
||||
Config.Server.Threading.thumbnailThreads;
|
||||
} else {
|
||||
Config.Media.Thumbnail.concurrentThumbnailGenerations = Math.max(
|
||||
1,
|
||||
os.cpus().length - 1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Config.Media.Thumbnail.concurrentThumbnailGenerations = 1;
|
||||
}
|
||||
|
||||
this.taskQue = new TaskExecuter(
|
||||
Config.Media.Thumbnail.concurrentThumbnailGenerations,
|
@ -1,11 +1,11 @@
|
||||
import * as path from 'path';
|
||||
import {constants as fsConstants, promises as fsp} from 'fs';
|
||||
import {ITaskExecuter, TaskExecuter} from '../threading/TaskExecuter';
|
||||
import {VideoConverterInput, VideoConverterWorker,} from '../threading/VideoConverterWorker';
|
||||
import {MetadataLoader} from '../threading/MetadataLoader';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import {SupportedFormats} from '../../../common/SupportedFormats';
|
||||
import {ITaskExecuter, TaskExecuter} from '../TaskExecuter';
|
||||
import {VideoConverterInput, VideoConverterWorker,} from '../VideoConverterWorker';
|
||||
import {MetadataLoader} from '../MetadataLoader';
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {SupportedFormats} from '../../../../common/SupportedFormats';
|
||||
|
||||
export class VideoProcessing {
|
||||
private static taskQue: ITaskExecuter<VideoConverterInput, void> =
|
@ -1,8 +1,6 @@
|
||||
import {ConfigTemplateEntry} from '../../../../common/entities/job/JobDTO';
|
||||
import {Job} from './Job';
|
||||
import * as path from 'path';
|
||||
import {DiskManager} from '../../DiskManger';
|
||||
import {DirectoryScanSettings} from '../../threading/DiskMangerWorker';
|
||||
import {Logger} from '../../../Logger';
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {FileDTO} from '../../../../common/entities/FileDTO';
|
||||
@ -14,6 +12,7 @@ import {backendTexts} from '../../../../common/BackendTexts';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {FileEntity} from '../../database/enitites/FileEntity';
|
||||
import {DirectoryBaseDTO, DirectoryDTOUtils} from '../../../../common/entities/DirectoryDTO';
|
||||
import {DirectoryScanSettings, DiskManager} from '../../fileaccess/DiskManager';
|
||||
|
||||
const LOG_TAG = '[FileJob]';
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {FileJob} from './FileJob';
|
||||
import {GPXProcessing} from '../../fileprocessing/GPXProcessing';
|
||||
import {FileDTO} from '../../../../common/entities/FileDTO';
|
||||
import {Logger} from '../../../Logger';
|
||||
import {GPXProcessing} from '../../fileaccess/fileprocessing/GPXProcessing';
|
||||
|
||||
export class GPXCompressionJob extends FileJob {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['GPX Compression']];
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {TempFolderCleaningJob} from './TempFolderCleaningJob';
|
||||
import {GPXProcessing} from '../../fileprocessing/GPXProcessing';
|
||||
import {GPXProcessing} from '../../fileaccess/fileprocessing/GPXProcessing';
|
||||
|
||||
/**
|
||||
* Deletes all gpx file from the tmp folder
|
||||
|
@ -4,12 +4,12 @@ import * as fs from 'fs';
|
||||
import {Job} from './Job';
|
||||
import {ConfigTemplateEntry, DefaultsJobs,} from '../../../../common/entities/job/JobDTO';
|
||||
import {JobProgressStates} from '../../../../common/entities/job/JobProgressDTO';
|
||||
import {DiskMangerWorker} from '../../threading/DiskMangerWorker';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {backendTexts} from '../../../../common/BackendTexts';
|
||||
import {ParentDirectoryDTO} from '../../../../common/entities/DirectoryDTO';
|
||||
import {Logger} from '../../../Logger';
|
||||
import {FileDTO} from '../../../../common/entities/FileDTO';
|
||||
import {DiskManager} from '../../fileaccess/DiskManager';
|
||||
|
||||
const LOG_TAG = '[IndexingJob]';
|
||||
|
||||
@ -62,7 +62,7 @@ export class IndexingJob<
|
||||
if (this.config.indexChangesOnly) {
|
||||
|
||||
const stat = fs.statSync(absDirPath);
|
||||
const lastModified = DiskMangerWorker.calcLastModified(stat);
|
||||
const lastModified = DiskManager.calcLastModified(stat);
|
||||
scanned = await ObjectManagers.getInstance().GalleryManager.selectDirStructure(directory);
|
||||
// If not modified and it was scanned before, dir is up-to-date
|
||||
if (
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {FileJob} from './FileJob';
|
||||
import {PhotoProcessing} from '../../fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from '../../fileaccess/fileprocessing/PhotoProcessing';
|
||||
|
||||
export class PhotoConvertingJob extends FileJob {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Photo Converting']];
|
||||
|
@ -3,9 +3,9 @@ import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import {Job} from './Job';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {PhotoProcessing} from '../../fileprocessing/PhotoProcessing';
|
||||
import {VideoProcessing} from '../../fileprocessing/VideoProcessing';
|
||||
import {GPXProcessing} from '../../fileprocessing/GPXProcessing';
|
||||
import {GPXProcessing} from '../../fileaccess/fileprocessing/GPXProcessing';
|
||||
import {PhotoProcessing} from '../../fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {VideoProcessing} from '../../fileaccess/fileprocessing/VideoProcessing';
|
||||
|
||||
export class TempFolderCleaningJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Temp Folder Cleaning']];
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {FileJob} from './FileJob';
|
||||
import {PhotoProcessing} from '../../fileprocessing/PhotoProcessing';
|
||||
import {ThumbnailSourceType} from '../../threading/PhotoWorker';
|
||||
import {PhotoProcessing} from '../../fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {ThumbnailSourceType} from '../../fileaccess/PhotoWorker';
|
||||
import {MediaDTOUtils} from '../../../../common/entities/MediaDTO';
|
||||
import {FileDTO} from '../../../../common/entities/FileDTO';
|
||||
import {backendTexts} from '../../../../common/BackendTexts';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Config} from '../../../../common/config/private/Config';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {FileJob} from './FileJob';
|
||||
import {VideoProcessing} from '../../fileprocessing/VideoProcessing';
|
||||
import {VideoProcessing} from '../../fileaccess/fileprocessing/VideoProcessing';
|
||||
|
||||
declare const global: any;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {createTransport, Transporter} from 'nodemailer';
|
||||
import {MediaDTO, MediaDTOUtils} from '../../../common/entities/MediaDTO';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {PhotoProcessing} from '../fileprocessing/PhotoProcessing';
|
||||
import {ThumbnailSourceType} from '../threading/PhotoWorker';
|
||||
import {PhotoProcessing} from '../fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {ThumbnailSourceType} from '../fileaccess/PhotoWorker';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import * as path from 'path';
|
||||
import {PhotoMetadata} from '../../../common/entities/PhotoDTO';
|
||||
|
@ -1,119 +0,0 @@
|
||||
import * as cluster from 'cluster';
|
||||
import {Worker} from 'cluster';
|
||||
import {Logger} from '../../Logger';
|
||||
import {DiskManagerTask, WorkerMessage, WorkerTask, WorkerTaskTypes,} from './Worker';
|
||||
import {ParentDirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
||||
import {TaskQue, TaskQueEntry} from './TaskQue';
|
||||
import {ITaskExecuter} from './TaskExecuter';
|
||||
import {DirectoryScanSettings} from './DiskMangerWorker';
|
||||
|
||||
interface WorkerWrapper<O> {
|
||||
worker: Worker;
|
||||
poolTask: TaskQueEntry<WorkerTask, O>;
|
||||
}
|
||||
|
||||
const LOG_TAG = '[ThreadPool]';
|
||||
|
||||
export class ThreadPool<O> {
|
||||
public static WorkerCount = 0;
|
||||
private workers: WorkerWrapper<O>[] = [];
|
||||
private taskQue = new TaskQue<WorkerTask, O>();
|
||||
|
||||
constructor(private size: number) {
|
||||
Logger.silly(LOG_TAG, 'Creating thread pool with', size, 'workers');
|
||||
for (let i = 0; i < size; i++) {
|
||||
this.startWorker();
|
||||
}
|
||||
}
|
||||
|
||||
protected executeTask(task: WorkerTask): Promise<O> {
|
||||
const promise = this.taskQue.add(task).promise.obj;
|
||||
this.run();
|
||||
return promise;
|
||||
}
|
||||
|
||||
private run = (): void => {
|
||||
if (this.taskQue.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
const worker = this.getFreeWorker();
|
||||
if (worker == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const poolTask = this.taskQue.get();
|
||||
worker.poolTask = poolTask;
|
||||
worker.worker.send(poolTask.data);
|
||||
};
|
||||
|
||||
private getFreeWorker(): null | WorkerWrapper<O> {
|
||||
for (const worker of this.workers) {
|
||||
if (worker.poolTask == null) {
|
||||
return worker;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private startWorker(): void {
|
||||
const worker = {
|
||||
poolTask: null,
|
||||
worker: (cluster as any).fork(),
|
||||
} as WorkerWrapper<O>;
|
||||
this.workers.push(worker);
|
||||
worker.worker.on('online', (): void => {
|
||||
ThreadPool.WorkerCount++;
|
||||
Logger.debug(
|
||||
LOG_TAG,
|
||||
'Worker ' + worker.worker.process.pid + ' is online, worker count:',
|
||||
ThreadPool.WorkerCount
|
||||
);
|
||||
});
|
||||
worker.worker.on('exit', (code, signal): void => {
|
||||
ThreadPool.WorkerCount--;
|
||||
Logger.warn(
|
||||
LOG_TAG,
|
||||
'Worker ' +
|
||||
worker.worker.process.pid +
|
||||
' died with code: ' +
|
||||
code +
|
||||
', and signal: ' +
|
||||
signal +
|
||||
', worker count:',
|
||||
ThreadPool.WorkerCount
|
||||
);
|
||||
Logger.debug(LOG_TAG, 'Starting a new worker');
|
||||
this.startWorker();
|
||||
});
|
||||
|
||||
worker.worker.on('message', (msg: WorkerMessage<O>): void => {
|
||||
if (worker.poolTask == null) {
|
||||
throw new Error('No worker task after worker task is completed');
|
||||
}
|
||||
if (msg.error) {
|
||||
worker.poolTask.promise.reject(msg.error);
|
||||
} else {
|
||||
worker.poolTask.promise.resolve(msg.result);
|
||||
}
|
||||
this.taskQue.ready(worker.poolTask);
|
||||
worker.poolTask = null;
|
||||
this.run();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class DiskManagerTH
|
||||
extends ThreadPool<ParentDirectoryDTO>
|
||||
implements ITaskExecuter<string, ParentDirectoryDTO> {
|
||||
execute(
|
||||
relativeDirectoryName: string,
|
||||
settings: DirectoryScanSettings = {}
|
||||
): Promise<ParentDirectoryDTO> {
|
||||
return super.executeTask({
|
||||
type: WorkerTaskTypes.diskManager,
|
||||
relativeDirectoryName,
|
||||
settings,
|
||||
} as DiskManagerTask);
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
import {DirectoryScanSettings, DiskMangerWorker} from './DiskMangerWorker';
|
||||
import {Logger} from '../../Logger';
|
||||
import {MediaRendererInput, PhotoWorker} from './PhotoWorker';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {ParentDirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
||||
|
||||
declare const process: NodeJS.Process;
|
||||
const LOG_TAG = '[Worker]';
|
||||
|
||||
export class Worker {
|
||||
public static process<O extends void | ParentDirectoryDTO<MediaDTO>>(): void {
|
||||
Logger.debug(LOG_TAG, 'Worker is waiting for tasks');
|
||||
process.on('message', async (task: WorkerTask) => {
|
||||
try {
|
||||
let result = null;
|
||||
switch (task.type) {
|
||||
case WorkerTaskTypes.diskManager:
|
||||
result = await DiskMangerWorker.scanDirectory(
|
||||
(task as DiskManagerTask).relativeDirectoryName,
|
||||
(task as DiskManagerTask).settings
|
||||
);
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
break;
|
||||
case WorkerTaskTypes.thumbnail:
|
||||
result = await PhotoWorker.render((task as ThumbnailTask).input);
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown worker task type');
|
||||
}
|
||||
process.send({
|
||||
error: null,
|
||||
result,
|
||||
} as WorkerMessage<O>);
|
||||
} catch (err) {
|
||||
process.send({error: err, result: null});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export enum WorkerTaskTypes {
|
||||
thumbnail = 1,
|
||||
diskManager = 2,
|
||||
}
|
||||
|
||||
export interface WorkerTask {
|
||||
type: WorkerTaskTypes;
|
||||
}
|
||||
|
||||
export interface DiskManagerTask extends WorkerTask {
|
||||
relativeDirectoryName: string;
|
||||
settings: DirectoryScanSettings;
|
||||
}
|
||||
|
||||
export interface ThumbnailTask extends WorkerTask {
|
||||
input: MediaRendererInput;
|
||||
}
|
||||
|
||||
export const WorkerTask = {
|
||||
equals: (t1: WorkerTask, t2: WorkerTask): boolean => {
|
||||
return Utils.equalsFilter(t1, t2);
|
||||
},
|
||||
};
|
||||
|
||||
export interface WorkerMessage<O> {
|
||||
error: Error;
|
||||
result: O;
|
||||
}
|
@ -4,7 +4,7 @@ import {GalleryMWs} from '../middlewares/GalleryMWs';
|
||||
import {RenderingMWs} from '../middlewares/RenderingMWs';
|
||||
import {ThumbnailGeneratorMWs} from '../middlewares/thumbnail/ThumbnailGeneratorMWs';
|
||||
import {UserRoles} from '../../common/entities/UserDTO';
|
||||
import {ThumbnailSourceType} from '../model/threading/PhotoWorker';
|
||||
import {ThumbnailSourceType} from '../model/fileaccess/PhotoWorker';
|
||||
import {VersionMWs} from '../middlewares/VersionMWs';
|
||||
import {SupportedFormats} from '../../common/SupportedFormats';
|
||||
import {PhotoConverterMWs} from '../middlewares/thumbnail/PhotoConverterMWs';
|
||||
|
@ -11,7 +11,7 @@ import {UserDTO} from '../../common/entities/UserDTO';
|
||||
import {ServerTimeEntry} from '../middlewares/ServerTimingMWs';
|
||||
import {ClientConfig, TAGS} from '../../common/config/public/ClientConfig';
|
||||
import {QueryParams} from '../../common/QueryParams';
|
||||
import {PhotoProcessing} from '../model/fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from '../model/fileaccess/fileprocessing/PhotoProcessing';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
|
@ -10,12 +10,11 @@ import * as locale from 'locale';
|
||||
import {ObjectManagers} from './model/ObjectManagers';
|
||||
import {Logger} from './Logger';
|
||||
import {LoggerRouter} from './routes/LoggerRouter';
|
||||
import {DiskManager} from './model/DiskManger';
|
||||
import {ConfigDiagnostics} from './model/diagnostics/ConfigDiagnostics';
|
||||
import {Localizations} from './model/Localizations';
|
||||
import {CookieNames} from '../common/CookieNames';
|
||||
import {Router} from './routes/Router';
|
||||
import {PhotoProcessing} from './model/fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from './model/fileaccess/fileprocessing/PhotoProcessing';
|
||||
import * as _csrf from 'csurf';
|
||||
import {Event} from '../common/event/Event';
|
||||
import {QueryParams} from '../common/QueryParams';
|
||||
@ -112,7 +111,6 @@ export class Server {
|
||||
_csrf({ignoreMethods: ['GET']})
|
||||
);
|
||||
|
||||
DiskManager.init();
|
||||
PhotoProcessing.init();
|
||||
Localizations.init();
|
||||
|
||||
|
@ -477,30 +477,6 @@ export class ServerIndexingConfig {
|
||||
excludeFileList: string[] = [];
|
||||
}
|
||||
|
||||
@SubConfigClass({softReadonly: true})
|
||||
export class ServerThreadingConfig {
|
||||
@ConfigProperty({
|
||||
tags:
|
||||
{
|
||||
name: $localize`Threading`,
|
||||
uiResetNeeded: {server: true},
|
||||
priority: ConfigPriority.underTheHood,
|
||||
} as TAGS,
|
||||
description: $localize`[Deprecated, will be removed in the next release] Runs directory scanning and thumbnail generation in a different thread.`
|
||||
})
|
||||
enabled: boolean = false;
|
||||
@ConfigProperty({
|
||||
tags:
|
||||
{
|
||||
name: $localize`Thumbnail threads`,
|
||||
uiResetNeeded: {server: true},
|
||||
priority: ConfigPriority.underTheHood
|
||||
},
|
||||
description: $localize`Number of threads that are used to generate thumbnails. If 0, number of 'CPU cores -1' threads will be used.`,
|
||||
})
|
||||
thumbnailThreads: number = 0; // if zero-> CPU count -1
|
||||
}
|
||||
|
||||
@SubConfigClass({softReadonly: true})
|
||||
export class ServerDuplicatesConfig {
|
||||
@ConfigProperty({
|
||||
@ -1028,14 +1004,6 @@ export class ServerServiceConfig extends ClientServiceConfig {
|
||||
})
|
||||
host: string = '0.0.0.0';
|
||||
|
||||
@ConfigProperty({
|
||||
tags: {
|
||||
name: $localize`Threading`,
|
||||
priority: ConfigPriority.underTheHood,
|
||||
}
|
||||
})
|
||||
Threading: ServerThreadingConfig = new ServerThreadingConfig();
|
||||
|
||||
@ConfigProperty({
|
||||
tags: {
|
||||
name: $localize`Logs`,
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
} from '../src/common/entities/PhotoDTO';
|
||||
import {DirectoryBaseDTO, DirectoryPathDTO} from '../src/common/entities/DirectoryDTO';
|
||||
import {FileDTO} from '../src/common/entities/FileDTO';
|
||||
import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
|
||||
import {DiskManager} from '../src/backend/model/fileaccess/DiskManager';
|
||||
|
||||
export class TestHelper {
|
||||
|
||||
@ -29,7 +29,7 @@ export class TestHelper {
|
||||
|
||||
const dir = new DirectoryEntity();
|
||||
dir.name = name;
|
||||
dir.path = DiskMangerWorker.pathFromParent({path: '', name: '.'});
|
||||
dir.path = DiskManager.pathFromParent({path: '', name: '.'});
|
||||
dir.mediaCount = 0;
|
||||
dir.youngestMedia = 10;
|
||||
dir.oldestMedia = 1000;
|
||||
@ -40,7 +40,7 @@ export class TestHelper {
|
||||
dir.lastScanned = 1656069687773;
|
||||
// dir.parent = null;
|
||||
if (parent !== null) {
|
||||
dir.path = DiskMangerWorker.pathFromParent(parent);
|
||||
dir.path = DiskManager.pathFromParent(parent);
|
||||
parent.directories.push(dir);
|
||||
}
|
||||
return dir;
|
||||
@ -299,8 +299,8 @@ export class TestHelper {
|
||||
|
||||
const dir: DirectoryBaseDTO = {
|
||||
id: null,
|
||||
name: DiskMangerWorker.dirName(forceStr || Math.random().toString(36).substring(7)),
|
||||
path: DiskMangerWorker.pathFromParent({path: '', name: '.'}),
|
||||
name: DiskManager.dirName(forceStr || Math.random().toString(36).substring(7)),
|
||||
path: DiskManager.pathFromParent({path: '', name: '.'}),
|
||||
mediaCount: 0,
|
||||
youngestMedia: 10,
|
||||
oldestMedia: 1000,
|
||||
@ -314,7 +314,7 @@ export class TestHelper {
|
||||
parent
|
||||
};
|
||||
if (parent !== null) {
|
||||
dir.path = DiskMangerWorker.pathFromParent(parent);
|
||||
dir.path = DiskManager.pathFromParent(parent);
|
||||
parent.directories.push(dir);
|
||||
}
|
||||
return dir;
|
||||
|
@ -6,7 +6,7 @@ import {DatabaseType, LogLevel} from '../../src/common/config/private/PrivateCon
|
||||
import {ProjectPath} from '../../src/backend/ProjectPath';
|
||||
import {DirectoryBaseDTO, ParentDirectoryDTO, SubDirectoryDTO} from '../../src/common/entities/DirectoryDTO';
|
||||
import {ObjectManagers} from '../../src/backend/model/ObjectManagers';
|
||||
import {DiskMangerWorker} from '../../src/backend/model/threading/DiskMangerWorker';
|
||||
import {DiskManager} from '../../src/backend/model/fileaccess/DiskManager';
|
||||
import {IndexingManager} from '../../src/backend/model/database/IndexingManager';
|
||||
import {GalleryManager} from '../../src/backend/model/database/GalleryManager';
|
||||
import {Connection} from 'typeorm';
|
||||
@ -135,7 +135,7 @@ export class DBTestHelper {
|
||||
for (let i = 0; i < d.directories.length; i++) {
|
||||
d.directories[i] = await gm.getParentDirFromId(connection,
|
||||
(await gm.getDirIdAndTime(connection, d.directories[i].name,
|
||||
path.join(DiskMangerWorker.pathFromParent(d), path.sep))).id);
|
||||
path.join(DiskManager.pathFromParent(d), path.sep))).id);
|
||||
await populateDir(d.directories[i]);
|
||||
}
|
||||
};
|
||||
|
@ -30,7 +30,6 @@ describe('GalleryRouter', (sqlHelper: DBTestHelper) => {
|
||||
const setUp = async () => {
|
||||
await sqlHelper.initDB();
|
||||
Config.Users.authenticationRequired = false;
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Media.Video.enabled = true;
|
||||
Config.Media.folder = path.join(__dirname, '../../assets');
|
||||
Config.Media.tempFolder = tempDir;
|
||||
|
@ -34,7 +34,6 @@ describe('PublicRouter', () => {
|
||||
const setUp = async () => {
|
||||
await fs.promises.rm(tempDir, {recursive: true, force: true});
|
||||
Config.Users.authenticationRequired = true;
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Sharing.enabled = true;
|
||||
Config.Database.type = DatabaseType.sqlite;
|
||||
Config.Database.dbFolder = tempDir;
|
||||
|
@ -35,7 +35,6 @@ describe('SharingRouter', () => {
|
||||
const setUp = async () => {
|
||||
await fs.promises.rm(tempDir, {recursive: true, force: true});
|
||||
Config.Users.authenticationRequired = true;
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Sharing.enabled = true;
|
||||
Config.Database.type = DatabaseType.sqlite;
|
||||
Config.Database.dbFolder = tempDir;
|
||||
|
@ -35,7 +35,6 @@ describe('UserRouter', () => {
|
||||
let server: Server;
|
||||
const setUp = async () => {
|
||||
await fs.promises.rm(tempDir, {recursive: true, force: true});
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Database.type = DatabaseType.sqlite;
|
||||
Config.Database.dbFolder = tempDir;
|
||||
ProjectPath.reset();
|
||||
|
@ -19,7 +19,6 @@ describe('SettingsRouter', () => {
|
||||
const tempDir = path.join(__dirname, '../../tmp');
|
||||
beforeEach(async () => {
|
||||
await fs.promises.rm(tempDir, {recursive: true, force: true});
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Database.type = DatabaseType.sqlite;
|
||||
Config.Database.dbFolder = tempDir;
|
||||
ProjectPath.reset();
|
||||
|
@ -2,7 +2,7 @@ import {expect} from 'chai';
|
||||
import {Config} from '../../../../../src/common/config/private/Config';
|
||||
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
|
||||
import * as path from 'path';
|
||||
import {PhotoProcessing} from '../../../../../src/backend/model/fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from '../../../../../src/backend/model/fileaccess/fileprocessing/PhotoProcessing';
|
||||
|
||||
|
||||
describe('PhotoProcessing', () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {expect} from 'chai';
|
||||
import {VideoProcessing} from '../../../../../src/backend/model/fileprocessing/VideoProcessing';
|
||||
import {VideoProcessing} from '../../../../../src/backend/model/fileaccess/fileprocessing/VideoProcessing';
|
||||
import {Config} from '../../../../../src/common/config/private/Config';
|
||||
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
|
||||
import * as path from 'path';
|
||||
|
@ -11,15 +11,14 @@ import {FileDTO} from '../../../../../src/common/entities/FileDTO';
|
||||
import {IndexingManager} from '../../../../../src/backend/model/database/IndexingManager';
|
||||
import {ObjectManagers} from '../../../../../src/backend/model/ObjectManagers';
|
||||
import {DBTestHelper} from '../../../DBTestHelper';
|
||||
import {DiskMangerWorker} from '../../../../../src/backend/model/threading/DiskMangerWorker';
|
||||
import {ReIndexingSensitivity} from '../../../../../src/common/config/private/PrivateConfig';
|
||||
import {SearchQueryTypes, TextSearch, TextSearchQueryMatchTypes} from '../../../../../src/common/entities/SearchQueryDTO';
|
||||
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
|
||||
import * as path from 'path';
|
||||
import {DiskManager} from '../../../../../src/backend/model/DiskManger';
|
||||
import {AlbumManager} from '../../../../../src/backend/model/database/AlbumManager';
|
||||
import {SortByTypes} from '../../../../../src/common/entities/SortingMethods';
|
||||
import {ClientSortingConfig} from '../../../../../src/common/config/public/ClientConfig';
|
||||
import { DiskManager } from '../../../../../src/backend/model/fileaccess/DiskManager';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const deepEqualInAnyOrder = require('deep-equal-in-any-order');
|
||||
@ -162,7 +161,6 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
||||
|
||||
ProjectPath.reset();
|
||||
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
||||
Config.Server.Threading.enabled = false;
|
||||
|
||||
await ObjectManagers.getInstance().IndexingManager.indexDirectory('.');
|
||||
if (ObjectManagers.getInstance().IndexingManager.IsSavingInProgress) {
|
||||
@ -353,7 +351,7 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
||||
const p1 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo1');
|
||||
|
||||
const subDir = TestHelper.getRandomizedDirectoryEntry(null, 'subDir');
|
||||
subDir.path = DiskMangerWorker.pathFromParent(parent);
|
||||
subDir.path = DiskManager.pathFromParent(parent);
|
||||
const sp1 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto1', 0);
|
||||
sp1.metadata.rating = 5;
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2', 0);
|
||||
@ -391,7 +389,7 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
||||
const p1 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo1');
|
||||
|
||||
const subDir = TestHelper.getRandomizedDirectoryEntry(null, 'subDir');
|
||||
subDir.path = DiskMangerWorker.pathFromParent(parent);
|
||||
subDir.path = DiskManager.pathFromParent(parent);
|
||||
const sp1 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto1', 0);
|
||||
sp1.metadata.rating = 5;
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2', 0);
|
||||
@ -636,7 +634,6 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
||||
}) as any).timeout(40000);
|
||||
|
||||
it('should save .md with date', async () => {
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Album.enabled = true;
|
||||
Config.Faces.enabled = true;
|
||||
|
||||
@ -721,7 +718,6 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
||||
|
||||
|
||||
it('.saved_searches.pg2conf', async () => {
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Album.enabled = true;
|
||||
Config.Faces.enabled = true;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {expect} from 'chai';
|
||||
import {DiskMangerWorker} from '../../../../../src/backend/model/threading/DiskMangerWorker';
|
||||
import * as path from 'path';
|
||||
import {Config} from '../../../../../src/common/config/private/Config';
|
||||
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
|
||||
import {Utils} from '../../../../../src/common/Utils';
|
||||
import {DatabaseType} from '../../../../../src/common/config/private/PrivateConfig';
|
||||
import {DiskManager} from '../../../../../src/backend/model/fileaccess/DiskManager';
|
||||
|
||||
declare const before: any;
|
||||
|
||||
@ -21,7 +21,7 @@ describe('DiskMangerWorker', () => {
|
||||
it('should parse metadata', async () => {
|
||||
Config.Media.folder = path.join(__dirname, '/../../../assets');
|
||||
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
||||
const dir = await DiskMangerWorker.scanDirectory('/');
|
||||
const dir = await DiskManager.scanDirectory('/');
|
||||
// should match the number of media (photo/video) files in the assets folder
|
||||
expect(dir.media.length).to.be.equals(10);
|
||||
const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json'));
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import {expect} from 'chai';
|
||||
import {MetadataLoader} from '../../../../../src/backend/model/threading/MetadataLoader';
|
||||
import {MetadataLoader} from '../../../../../src/backend/model/fileaccess/MetadataLoader';
|
||||
import {Utils} from '../../../../../src/common/Utils';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import {PhotoProcessing} from '../../../../../src/backend/model/fileprocessing/PhotoProcessing';
|
||||
import {PhotoProcessing} from '../../../../../src/backend/model/fileaccess/fileprocessing/PhotoProcessing';
|
||||
import {Config} from '../../../../../src/common/config/private/Config';
|
||||
import {DatabaseType} from '../../../../../src/common/config/private/PrivateConfig';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {expect} from 'chai';
|
||||
import {TaskExecuter} from '../../../../../src/backend/model/threading/TaskExecuter';
|
||||
import {TaskExecuter} from '../../../../../src/backend/model/fileaccess/TaskExecuter';
|
||||
|
||||
describe('TaskExecuter', () => {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {expect} from 'chai';
|
||||
import {TaskQue} from '../../../../../src/backend/model/threading/TaskQue';
|
||||
import {TaskQue} from '../../../../../src/backend/model/fileaccess/TaskQue';
|
||||
|
||||
describe('TaskQue', () => {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user