1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-11-28 08:58:49 +02:00

Project cleanup

This commit is contained in:
Patrik J. Braun 2021-01-04 10:32:19 +01:00
parent bd60900f7c
commit 2f0d2a5e59
15 changed files with 81 additions and 133 deletions

View File

@ -2,9 +2,8 @@ import {Config} from '../src/common/config/private/Config';
import {ObjectManagers} from '../src/backend/model/ObjectManagers';
import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
import {IndexingManager} from '../src/backend/model/database/sql/IndexingManager';
import * as util from 'util';
import * as path from 'path';
import * as rimraf from 'rimraf';
import * as fs from 'fs';
import {SearchTypes} from '../src/common/entities/AutoCompleteItem';
import {Utils} from '../src/common/Utils';
import {DirectoryDTO} from '../src/common/entities/DirectoryDTO';
@ -23,7 +22,6 @@ import {Express} from 'express';
import {PersonRouter} from '../src/backend/routes/PersonRouter';
import {QueryParams} from '../src/common/QueryParams';
const rimrafPR = util.promisify(rimraf);
export interface BenchmarkResult {
name: string;
@ -105,9 +103,9 @@ export class BenchmarkRunner {
}
async bmListDirectory(): Promise<BenchmarkResult> {
Config.Server.Indexing.reIndexingSensitivity = ServerConfig.ReIndexingSensitivity.low;
await this.init();
await this.setupDB();
Config.Server.Indexing.reIndexingSensitivity = ServerConfig.ReIndexingSensitivity.low;
const req = Utils.clone(this.requestTemplate);
req.params.directory = this.biggestDirPath;
const bm = new Benchmark('List directory', req,
@ -209,17 +207,17 @@ export class BenchmarkRunner {
private resetDB = async () => {
Config.Server.Threading.enabled = false;
await ObjectManagers.reset();
await rimrafPR(ProjectPath.DBFolder);
await fs.promises.rmdir(ProjectPath.DBFolder, {recursive: true});
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
Config.Server.Jobs.scheduled = [];
await ObjectManagers.InitSQLManagers();
};
private setupDB(): Promise<void> {
private async setupDB(): Promise<void> {
Config.Server.Threading.enabled = false;
return new Promise<void>(async (resolve, reject) => {
await this.resetDB();
await new Promise<void>((resolve, reject) => {
try {
await this.resetDB();
const indexingJob = new IndexingJob();
indexingJob.JobListener = {

81
package-lock.json generated
View File

@ -5275,7 +5275,6 @@
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.0.0.tgz",
"integrity": "sha512-jB0yCBl4W/kVHM2whjfyqnxTmOHkCX4kHEa5nYKSoGeYe8YrjTYTc87/6bwt1g8cmV0QrbhKriETg9jWtcREhg==",
"optional": true,
"requires": {
"node-addon-api": "^3.0.0",
"node-pre-gyp": "0.15.0"
@ -5289,11 +5288,6 @@
"tweetnacl": "^0.14.3"
}
},
"bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms="
},
"beeper": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz",
@ -5331,7 +5325,6 @@
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz",
"integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==",
"optional": true,
"requires": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",
@ -5342,7 +5335,6 @@
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"optional": true,
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
@ -5351,14 +5343,12 @@
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"optional": true
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"optional": true,
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
@ -6476,7 +6466,6 @@
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/color/-/color-3.1.3.tgz",
"integrity": "sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ==",
"optional": true,
"requires": {
"color-convert": "^1.9.1",
"color-string": "^1.5.4"
@ -6499,7 +6488,6 @@
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.4.tgz",
"integrity": "sha512-57yF5yt8Xa3czSEW1jfQDE79Idk0+AkN/4KWad6tbdxUmAs3MvjxlWSWD4deYytcRfoZ9nhKyFl1kj5tBvidbw==",
"optional": true,
"requires": {
"color-name": "^1.0.0",
"simple-swizzle": "^0.2.2"
@ -8630,8 +8618,7 @@
"expand-template": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz",
"integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==",
"optional": true
"integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg=="
},
"expand-tilde": {
"version": "2.0.2",
@ -9235,8 +9222,7 @@
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
"optional": true
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
},
"fs-extra": {
"version": "7.0.1",
@ -9403,8 +9389,7 @@
"github-from-package": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=",
"optional": true
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4="
},
"glob": {
"version": "7.1.3",
@ -11319,8 +11304,7 @@
"is-arrayish": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==",
"optional": true
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
},
"is-binary-path": {
"version": "2.1.0",
@ -13600,8 +13584,7 @@
"mkdirp-classic": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
"optional": true
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
},
"mocha": {
"version": "8.1.3",
@ -14109,8 +14092,7 @@
"napi-build-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz",
"integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==",
"optional": true
"integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg=="
},
"needle": {
"version": "2.5.2",
@ -14195,7 +14177,6 @@
"version": "2.19.3",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.19.3.tgz",
"integrity": "sha512-9xZrlyfvKhWme2EXFKQhZRp1yNWT/uI1luYPr3sFl+H4keYY4xR+1jO7mvTTijIsHf1M+QDe9uWuKeEpLInIlg==",
"optional": true,
"requires": {
"semver": "^5.4.1"
}
@ -14203,8 +14184,7 @@
"node-addon-api": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz",
"integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg==",
"optional": true
"integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg=="
},
"node-fetch-npm": {
"version": "2.0.2",
@ -14340,7 +14320,6 @@
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.15.0.tgz",
"integrity": "sha512-7QcZa8/fpaU/BKenjcaeFF9hLz2+7S9AqyXFhlH/rilsQ/hPZKK32RtR5EQHJElgu+q5RfbJ34KriI79UWaorA==",
"optional": true,
"requires": {
"detect-libc": "^1.0.2",
"mkdirp": "^0.5.3",
@ -14357,14 +14336,12 @@
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"optional": true
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"optional": true,
"requires": {
"minimist": "^1.2.5"
}
@ -14373,7 +14350,6 @@
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
"optional": true,
"requires": {
"glob": "^7.1.3"
}
@ -14409,8 +14385,7 @@
"noop-logger": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz",
"integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=",
"optional": true
"integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI="
},
"nopt": {
"version": "4.0.1",
@ -16069,7 +16044,6 @@
"version": "5.3.6",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.6.tgz",
"integrity": "sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==",
"optional": true,
"requires": {
"detect-libc": "^1.0.3",
"expand-template": "^2.0.3",
@ -16091,14 +16065,12 @@
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"optional": true
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"pump": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
"optional": true,
"requires": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
@ -17266,6 +17238,7 @@
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}
@ -17642,7 +17615,6 @@
"version": "0.23.4",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.23.4.tgz",
"integrity": "sha512-fJMagt6cT0UDy9XCsgyLi0eiwWWhQRxbwGmqQT6sY8Av4s0SVsT/deg8fobBQCTDU5iXRgz0rAeXoE2LBZ8g+Q==",
"optional": true,
"requires": {
"color": "^3.1.2",
"detect-libc": "^1.0.3",
@ -17659,7 +17631,6 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
"integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==",
"optional": true,
"requires": {
"minipass": "^3.0.0"
}
@ -17668,7 +17639,6 @@
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz",
"integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==",
"optional": true,
"requires": {
"yallist": "^4.0.0"
}
@ -17677,7 +17647,6 @@
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz",
"integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==",
"optional": true,
"requires": {
"minipass": "^3.0.0",
"yallist": "^4.0.0"
@ -17686,20 +17655,17 @@
"nan": {
"version": "2.14.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz",
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==",
"optional": true
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"optional": true
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
},
"tar": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/tar/-/tar-5.0.5.tgz",
"integrity": "sha512-MNIgJddrV2TkuwChwcSNds/5E9VijOiw7kAc1y5hTNJoLDSuIyid2QtLYiCYNnICebpuvjhPQZsXwUL0O3l7OQ==",
"optional": true,
"requires": {
"chownr": "^1.1.3",
"fs-minipass": "^2.0.0",
@ -17712,8 +17678,7 @@
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"optional": true
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
}
},
@ -17746,14 +17711,12 @@
"simple-concat": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
"optional": true
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="
},
"simple-get": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz",
"integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
"optional": true,
"requires": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
@ -17764,7 +17727,6 @@
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
"optional": true,
"requires": {
"mimic-response": "^2.0.0"
}
@ -17772,8 +17734,7 @@
"mimic-response": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
"optional": true
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA=="
}
}
},
@ -17781,7 +17742,6 @@
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
"integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=",
"optional": true,
"requires": {
"is-arrayish": "^0.3.1"
}
@ -18881,7 +18841,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
"optional": true,
"requires": {
"chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2",
@ -18893,7 +18852,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
"optional": true,
"requires": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
@ -18905,7 +18863,6 @@
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
"optional": true,
"requires": {
"bl": "^4.0.3",
"end-of-stream": "^1.4.1",
@ -18918,7 +18875,6 @@
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"optional": true,
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
@ -21893,8 +21849,7 @@
"which-pm-runs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz",
"integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=",
"optional": true
"integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs="
},
"wide-align": {
"version": "1.1.3",

View File

@ -30,12 +30,13 @@
"url": "https://github.com/bpatrik/PiGallery2/issues"
},
"dependencies": {
"bcryptjs": "2.4.3",
"body-parser": "1.19.0",
"cookie-parser": "1.4.5",
"cookie-session": "2.0.0-beta.3",
"csurf": "1.11.0",
"ejs": "3.1.5",
"bcrypt": "5.0.0",
"sharp": "0.23.4",
"exifreader": "3.12.2",
"express": "4.17.1",
"express-unless": "0.5.0",
@ -44,7 +45,6 @@
"jimp": "0.16.1",
"locale": "0.1.0",
"reflect-metadata": "0.1.13",
"rimraf": "3.0.2",
"sqlite3": "5.0.0",
"ts-exif-parser": "0.2.1",
"ts-node-iptc": "1.0.11",
@ -144,11 +144,9 @@
"optionalDependencies": {
"@ffmpeg-installer/ffmpeg": "1.0.20",
"@ffprobe-installer/ffprobe": "1.1.0",
"bcrypt": "5.0.0",
"mysql": "2.18.1",
"sharp": "0.23.4"
"mysql": "2.18.1"
},
"engines": {
"node": ">=10.17 <15.0"
"node": ">=12.0 <15.0"
}
}

View File

@ -13,7 +13,7 @@ import {PersonWithSampleRegion} from '../../../common/entities/PersonDTO';
export class ThumbnailGeneratorMWs {
public static addThumbnailInformation(req: Request, res: Response, next: NextFunction) {
public static async addThumbnailInformation(req: Request, res: Response, next: NextFunction) {
if (!req.resultPipe) {
return next();
}

View File

@ -96,6 +96,10 @@ export class ObjectManagers {
}
public static async reset() {
if (ObjectManagers.getInstance().IndexingManager &&
ObjectManagers.getInstance().IndexingManager.IsSavingInProgress) {
await ObjectManagers.getInstance().IndexingManager.SavingReady;
}
if (ObjectManagers.getInstance().JobManager) {
ObjectManagers.getInstance().JobManager.stopSchedules();
}

View File

@ -23,7 +23,7 @@ const LOG_TAG = '[IndexingManager]';
export class IndexingManager implements IIndexingManager {
SavingReady: Promise<void> = null;
SavingReadyPR: () => void = null;
private SavingReadyPR: () => void = null;
private savingQueue: DirectoryDTO[] = [];
private isSaving = false;
@ -78,13 +78,20 @@ export class IndexingManager implements IIndexingManager {
this.SavingReadyPR = resolve;
});
}
while (this.isSaving === false && this.savingQueue.length > 0) {
await this.saveToDB(this.savingQueue[0]);
this.savingQueue.shift();
}
if (this.savingQueue.length === 0) {
this.SavingReady = null;
this.SavingReadyPR();
try {
while (this.isSaving === false && this.savingQueue.length > 0) {
await this.saveToDB(this.savingQueue[0]);
this.savingQueue.shift();
}
} catch (e) {
this.savingQueue = [];
throw e;
} finally {
if (this.savingQueue.length === 0) {
this.SavingReady = null;
this.SavingReadyPR();
}
}
}

View File

@ -99,14 +99,15 @@ export class PersonManager implements ISQLPersonManager {
private async updateCounts() {
const connection = await SQLConnection.getConnection();
await connection.query('update person_entry set count = ' +
' (select COUNT(1) from face_region_entry where face_region_entry.personId = person_entry.id)');
await connection.query('UPDATE person_entry SET count = ' +
' (SELECT COUNT(1) FROM face_region_entry WHERE face_region_entry.personId = person_entry.id)');
// remove persons without photo
await connection.getRepository(PersonEntry)
await connection
.createQueryBuilder()
.where('count = 0')
.delete()
.from(PersonEntry)
.where('count = 0')
.execute();
}

View File

@ -87,6 +87,8 @@ export class SQLConnection {
public static async init(): Promise<void> {
const connection = await this.getConnection();
// Add dummy Admin to the db
const userRepository = connection.getRepository(UserEntity);
const admins = await userRepository.find({role: UserRoles.Admin});
if (admins.length === 0) {

View File

@ -1,14 +1,10 @@
import {ConfigTemplateEntry, DefaultsJobs} from '../../../../common/entities/job/JobDTO';
import * as path from 'path';
import * as util from 'util';
import {promises as fsp} from 'fs';
import * as fs from 'fs';
import {Job} from './Job';
import {ProjectPath} from '../../../ProjectPath';
import {PhotoProcessing} from '../../fileprocessing/PhotoProcessing';
import {VideoProcessing} from '../../fileprocessing/VideoProcessing';
import * as rimraf from 'rimraf';
const rimrafPR = util.promisify(rimraf);
export class TempFolderCleaningJob extends Job {
@ -42,7 +38,7 @@ export class TempFolderCleaningJob extends Job {
const originalPath = path.join(ProjectPath.ImageFolder,
path.relative(ProjectPath.TranscodedFolder, filePath));
try {
await fsp.access(originalPath);
await fs.promises.access(originalPath);
return true;
} catch (e) {
}
@ -50,7 +46,7 @@ export class TempFolderCleaningJob extends Job {
}
protected async readDir(dirPath: string): Promise<string[]> {
return (await fsp.readdir(dirPath)).map(f => path.normalize(path.join(dirPath, f)));
return (await fs.promises.readdir(dirPath)).map(f => path.normalize(path.join(dirPath, f)));
}
protected async stepTempDirectory() {
@ -60,10 +56,10 @@ export class TempFolderCleaningJob extends Job {
if (validFiles.indexOf(files[i]) === -1) {
this.Progress.log('processing: ' + files[i]);
this.Progress.Processed++;
if ((await fsp.stat(files[i])).isDirectory()) {
await rimrafPR(files[i]);
if ((await fs.promises.stat(files[i])).isDirectory()) {
await fs.promises.rmdir(files[i], {recursive: true});
} else {
await fsp.unlink(files[i]);
await fs.promises.unlink(files[i]);
}
} else {
this.Progress.log('skipping: ' + files[i]);
@ -80,14 +76,14 @@ export class TempFolderCleaningJob extends Job {
protected async stepConvertedDirectory() {
const filePath = this.directoryQueue.shift();
const stat = await fsp.stat(filePath);
const stat = await fs.promises.stat(filePath);
this.Progress.Left = this.directoryQueue.length;
if (stat.isDirectory()) {
if (await this.isValidDirectory(filePath) === false) {
this.Progress.log('processing: ' + filePath);
this.Progress.Processed++;
await rimrafPR(filePath);
await fs.promises.rmdir(filePath, {recursive: true});
} else {
this.Progress.log('skipping: ' + filePath);
this.Progress.Skipped++;
@ -97,7 +93,7 @@ export class TempFolderCleaningJob extends Job {
if (await this.isValidFile(filePath) === false) {
this.Progress.log('processing: ' + filePath);
this.Progress.Processed++;
await fsp.unlink(filePath);
await fs.promises.unlink(filePath);
} else {
this.Progress.log('skipping: ' + filePath);
this.Progress.Skipped++;

View File

@ -1,14 +1,12 @@
import {Config} from '../../src/common/config/private/Config';
import * as path from 'path';
import * as util from 'util';
import * as rimraf from 'rimraf';
import * as fs from 'fs';
import {SQLConnection} from '../../src/backend/model/database/sql/SQLConnection';
import {ServerConfig} from '../../src/common/config/private/PrivateConfig';
import {ProjectPath} from '../../src/backend/ProjectPath';
declare let describe: any;
const savedDescribe = describe;
const rimrafPR = util.promisify(rimraf);
export class SQLTestHelper {
@ -76,7 +74,7 @@ export class SQLTestHelper {
private async resetSQLite() {
await SQLConnection.close();
await rimrafPR(this.tempDir);
await fs.promises.rmdir(this.tempDir, {recursive: true});
}
private async resetMySQL() {

View File

@ -1,7 +1,6 @@
import {expect} from 'chai';
import * as path from 'path';
import * as util from 'util';
import * as rimraf from 'rimraf';
import * as fs from 'fs';
import {Config} from '../../../../../src/common/config/private/Config';
import {SQLConnection} from '../../../../../src/backend/model/database/sql/SQLConnection';
import {UserEntity} from '../../../../../src/backend/model/database/sql/enitites/UserEntity';
@ -21,14 +20,12 @@ import {ServerConfig} from '../../../../../src/common/config/private/PrivateConf
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
const rimrafPR = util.promisify(rimraf);
describe('Typeorm integration', () => {
const tempDir = path.join(__dirname, '../../tmp');
const setUpSqlDB = async () => {
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
Config.Server.Database.dbFolder = tempDir;
@ -38,7 +35,7 @@ describe('Typeorm integration', () => {
const teardownUpSqlDB = async () => {
await SQLConnection.close();
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
};
beforeEach(async () => {

View File

@ -1,9 +1,8 @@
import {Config} from '../../../../src/common/config/private/Config';
import {Server} from '../../../../src/backend/server';
import * as path from 'path';
import * as util from 'util';
import * as fs from 'fs';
import {expect} from 'chai';
import * as rimraf from 'rimraf';
import {SQLConnection} from '../../../../src/backend/model/database/sql/SQLConnection';
import {SuperAgentStatic} from 'superagent';
import {ProjectPath} from '../../../../src/backend/ProjectPath';
@ -16,13 +15,12 @@ const chaiHttp = require('chai-http');
const should = chai.should();
chai.use(chaiHttp);
const rimrafPR = util.promisify(rimraf);
describe('GalleryRouter', () => {
const tempDir = path.join(__dirname, '../../tmp');
let server: Server;
const setUp = async () => {
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
Config.Client.authenticationRequired = false;
Config.Server.Threading.enabled = false;
Config.Client.Media.Video.enabled = true;
@ -38,7 +36,7 @@ describe('GalleryRouter', () => {
};
const tearDown = async () => {
await SQLConnection.close();
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
};

View File

@ -3,8 +3,7 @@ import {Server} from '../../../../src/backend/server';
import {LoginCredential} from '../../../../src/common/entities/LoginCredential';
import {UserDTO, UserRoles} from '../../../../src/common/entities/UserDTO';
import * as path from 'path';
import * as util from 'util';
import * as rimraf from 'rimraf';
import * as fs from 'fs';
import {SQLConnection} from '../../../../src/backend/model/database/sql/SQLConnection';
import {ObjectManagers} from '../../../../src/backend/model/ObjectManagers';
import {Utils} from '../../../../src/common/Utils';
@ -21,7 +20,6 @@ const chaiHttp = require('chai-http');
const should = chai.should();
chai.use(chaiHttp);
const rimrafPR = util.promisify(rimraf);
describe('SharingRouter', () => {
const testUser: UserDTO = {
@ -35,7 +33,7 @@ describe('SharingRouter', () => {
const tempDir = path.join(__dirname, '../../tmp');
let server: Server;
const setUp = async () => {
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
Config.Client.authenticationRequired = true;
Config.Server.Threading.enabled = false;
Config.Client.Sharing.enabled = true;
@ -51,7 +49,7 @@ describe('SharingRouter', () => {
};
const tearDown = async () => {
await SQLConnection.close();
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
};
const shouldBeValidUser = (result: any, user: any) => {

View File

@ -3,8 +3,7 @@ import {Server} from '../../../../src/backend/server';
import {LoginCredential} from '../../../../src/common/entities/LoginCredential';
import {UserDTO, UserRoles} from '../../../../src/common/entities/UserDTO';
import * as path from 'path';
import * as util from 'util';
import * as rimraf from 'rimraf';
import * as fs from 'fs';
import {SQLConnection} from '../../../../src/backend/model/database/sql/SQLConnection';
import {ObjectManagers} from '../../../../src/backend/model/ObjectManagers';
import {QueryParams} from '../../../../src/common/QueryParams';
@ -22,7 +21,6 @@ const chaiHttp = require('chai-http');
const should = chai.should();
chai.use(chaiHttp);
const rimrafPR = util.promisify(rimraf);
describe('UserRouter', () => {
const testUser: UserDTO = {
@ -36,7 +34,7 @@ describe('UserRouter', () => {
const tempDir = path.join(__dirname, '../../tmp');
let server: Server;
const setUp = async () => {
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
Config.Server.Threading.enabled = false;
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
Config.Server.Database.dbFolder = tempDir;
@ -51,7 +49,7 @@ describe('UserRouter', () => {
};
const tearDown = async () => {
await SQLConnection.close();
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
};
const checkUserResult = (result: any, user: any) => {

View File

@ -1,6 +1,5 @@
import * as path from 'path';
import * as util from 'util';
import * as rimraf from 'rimraf';
import * as fs from 'fs';
import {Config} from '../../../../../src/common/config/private/Config';
import {SQLConnection} from '../../../../../src/backend/model/database/sql/SQLConnection';
import {Server} from '../../../../../src/backend/server';
@ -13,12 +12,11 @@ const chaiHttp = require('chai-http');
const should = chai.should();
chai.use(chaiHttp);
const rimrafPR = util.promisify(rimraf);
describe('SettingsRouter', () => {
const tempDir = path.join(__dirname, '../../tmp');
beforeEach(async () => {
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
Config.Server.Threading.enabled = false;
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
Config.Server.Database.dbFolder = tempDir;
@ -28,7 +26,7 @@ describe('SettingsRouter', () => {
afterEach(async () => {
await SQLConnection.close();
await rimrafPR(tempDir);
await fs.promises.rmdir(tempDir, {recursive: true});
});
describe('/GET settings', () => {