mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Fixing preview generation
This commit is contained in:
parent
5e1b90187d
commit
acd130babd
@ -85,7 +85,7 @@ export class GalleryMWs {
|
||||
};
|
||||
|
||||
if (cw.directory) {
|
||||
DirectoryDTO.removeReferences(cw.directory);
|
||||
DirectoryDTO.packDirectory(cw.directory);
|
||||
// TODO: remove when typeorm inheritance is fixed (and handles proper inheritance)
|
||||
cleanUpMedia(cw.directory.media);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {ThumbnailSourceType} from '../../model/threading/PhotoWorker';
|
||||
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {PhotoProcessing} from '../../model/fileprocessing/PhotoProcessing';
|
||||
import {PersonWithSampleRegion} from '../../../common/entities/PersonDTO';
|
||||
|
||||
@ -138,11 +138,12 @@ export class ThumbnailGeneratorMWs {
|
||||
|
||||
|
||||
private static addThInfoTODir(directory: DirectoryDTO) {
|
||||
console.log(directory.path, directory.name);
|
||||
if (typeof directory.media !== 'undefined') {
|
||||
ThumbnailGeneratorMWs.addThInfoToPhotos(directory.media);
|
||||
}
|
||||
if (directory.preview) {
|
||||
ThumbnailGeneratorMWs.addThInfoToAPhoto(directory.preview);
|
||||
ThumbnailGeneratorMWs.addThInfoToAPhoto(directory.preview);
|
||||
}
|
||||
if (typeof directory.directories !== 'undefined') {
|
||||
for (let i = 0; i < directory.directories.length; i++) {
|
||||
@ -157,7 +158,7 @@ export class ThumbnailGeneratorMWs {
|
||||
}
|
||||
}
|
||||
|
||||
private static addThInfoToAPhoto(photo: MediaDTO) {
|
||||
private static addThInfoToAPhoto(photo: MediaBaseDTO) {
|
||||
const fullMediaPath = path.join(ProjectPath.ImageFolder, photo.directory.path, photo.directory.name, photo.name);
|
||||
for (let j = 0; j < Config.Client.Media.Thumbnail.thumbnailSizes.length; j++) {
|
||||
const size = Config.Client.Media.Thumbnail.thumbnailSizes[j];
|
||||
|
@ -36,7 +36,7 @@ export class DiskManager {
|
||||
} else {
|
||||
directory = await DiskMangerWorker.scanDirectory(relativeDirectoryName, settings);
|
||||
}
|
||||
DirectoryDTO.addReferences(directory);
|
||||
DirectoryDTO.unpackDirectory(directory);
|
||||
return directory;
|
||||
}
|
||||
|
||||
|
@ -234,9 +234,9 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
|
||||
.getOne();
|
||||
|
||||
if (dir.preview) {
|
||||
dir.preview.directory = dir;
|
||||
dir.preview.readyThumbnails = [];
|
||||
dir.preview.readyIcon = false;
|
||||
console.log(dir.preview.directory);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import {Logger} from '../../Logger';
|
||||
import {SupportedFormats} from '../../../common/SupportedFormats';
|
||||
import {VideoProcessing} from '../fileprocessing/VideoProcessing';
|
||||
import {PhotoProcessing} from '../fileprocessing/PhotoProcessing';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
|
||||
|
||||
export class DiskMangerWorker {
|
||||
@ -132,6 +133,7 @@ export class DiskMangerWorker {
|
||||
|
||||
d.lastScanned = 0; // it was not a fully scan
|
||||
d.isPartial = true;
|
||||
|
||||
directory.directories.push(d);
|
||||
|
||||
} else if (PhotoProcessing.isPhoto(fullFilePath)) {
|
||||
@ -146,7 +148,12 @@ export class DiskMangerWorker {
|
||||
};
|
||||
|
||||
if (!directory.preview) {
|
||||
directory.preview = photo;
|
||||
directory.preview = Utils.clone(photo);
|
||||
|
||||
directory.preview.directory = {
|
||||
path: directory.path,
|
||||
name: directory.name
|
||||
};
|
||||
}
|
||||
// add the preview photo to the list of media, so it will be saved to the DB
|
||||
// and can be queried to populate previews,
|
||||
|
@ -1,8 +1,14 @@
|
||||
import {MediaDTO} from './MediaDTO';
|
||||
import {FileDTO} from './FileDTO';
|
||||
import {PhotoDTO} from './PhotoDTO';
|
||||
import {PhotoDTO, PreviewPhotoDTO} from './PhotoDTO';
|
||||
import {Utils} from '../Utils';
|
||||
|
||||
export interface DirectoryDTO<S extends FileDTO = MediaDTO> {
|
||||
export interface DirectoryBaseDTO {
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface DirectoryDTO<S extends FileDTO = MediaDTO> extends DirectoryBaseDTO {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
@ -12,20 +18,17 @@ export interface DirectoryDTO<S extends FileDTO = MediaDTO> {
|
||||
parent: DirectoryDTO<S>;
|
||||
mediaCount: number;
|
||||
directories: DirectoryDTO<S>[];
|
||||
preview: S;
|
||||
preview: PreviewPhotoDTO;
|
||||
media: S[];
|
||||
metaFile: FileDTO[];
|
||||
}
|
||||
|
||||
export module DirectoryDTO {
|
||||
export const addReferences = (dir: DirectoryDTO): void => {
|
||||
export const unpackDirectory = (dir: DirectoryDTO): void => {
|
||||
dir.media.forEach((media: MediaDTO) => {
|
||||
media.directory = dir;
|
||||
});
|
||||
|
||||
if (dir.preview) {
|
||||
dir.preview.directory = dir;
|
||||
}
|
||||
if (dir.metaFile) {
|
||||
dir.metaFile.forEach((file: FileDTO) => {
|
||||
file.directory = dir;
|
||||
@ -34,21 +37,30 @@ export module DirectoryDTO {
|
||||
|
||||
if (dir.directories) {
|
||||
dir.directories.forEach((directory: DirectoryDTO) => {
|
||||
addReferences(directory);
|
||||
unpackDirectory(directory);
|
||||
directory.parent = dir;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const removeReferences = (dir: DirectoryDTO): DirectoryDTO => {
|
||||
export const packDirectory = (dir: DirectoryDTO): DirectoryDTO => {
|
||||
if (dir.preview) {
|
||||
dir.preview.directory = {
|
||||
path: dir.preview.directory.path,
|
||||
name: dir.preview.directory.name,
|
||||
};
|
||||
|
||||
// make sure that it is not a same object as one of the photo in the media[]
|
||||
// as the next foreach would remove the directory
|
||||
dir.preview = Utils.clone(dir.preview);
|
||||
}
|
||||
|
||||
if (dir.media) {
|
||||
dir.media.forEach((media: MediaDTO) => {
|
||||
media.directory = null;
|
||||
});
|
||||
}
|
||||
if (dir.preview) {
|
||||
dir.preview.directory = null;
|
||||
}
|
||||
|
||||
if (dir.metaFile) {
|
||||
dir.metaFile.forEach((file: FileDTO) => {
|
||||
file.directory = null;
|
||||
@ -56,7 +68,7 @@ export module DirectoryDTO {
|
||||
}
|
||||
if (dir.directories) {
|
||||
dir.directories.forEach((directory: DirectoryDTO) => {
|
||||
removeReferences(directory);
|
||||
packDirectory(directory);
|
||||
directory.parent = null;
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
import {DirectoryDTO} from './DirectoryDTO';
|
||||
import {DirectoryBaseDTO, DirectoryDTO} from './DirectoryDTO';
|
||||
|
||||
export interface FileDTO {
|
||||
export interface FileBaseDTO {
|
||||
id: number;
|
||||
name: string;
|
||||
directory: DirectoryBaseDTO;
|
||||
}
|
||||
|
||||
export interface FileDTO extends FileBaseDTO {
|
||||
id: number;
|
||||
name: string;
|
||||
directory: DirectoryDTO;
|
||||
|
@ -1,14 +1,22 @@
|
||||
import {DirectoryDTO} from './DirectoryDTO';
|
||||
import {DirectoryBaseDTO, DirectoryDTO} from './DirectoryDTO';
|
||||
import {PhotoDTO} from './PhotoDTO';
|
||||
import {FileDTO} from './FileDTO';
|
||||
import {FileBaseDTO, FileDTO} from './FileDTO';
|
||||
import {SupportedFormats} from '../SupportedFormats';
|
||||
|
||||
export interface MediaDTO extends FileDTO {
|
||||
export interface MediaBaseDTO extends FileBaseDTO {
|
||||
name: string;
|
||||
directory: DirectoryBaseDTO;
|
||||
metadata: MediaMetadata;
|
||||
readyThumbnails: number[];
|
||||
readyIcon: boolean;
|
||||
}
|
||||
|
||||
export interface MediaDTO extends FileDTO, MediaBaseDTO {
|
||||
id: number;
|
||||
name: string;
|
||||
directory: DirectoryDTO;
|
||||
metadata: MediaMetadata;
|
||||
readyThumbnails: Array<number>;
|
||||
readyThumbnails: number[];
|
||||
readyIcon: boolean;
|
||||
|
||||
}
|
||||
@ -27,7 +35,7 @@ export interface MediaDimension {
|
||||
}
|
||||
|
||||
export module MediaDTO {
|
||||
export const hasPositionData = (media: MediaDTO): boolean => {
|
||||
export const hasPositionData = (media: MediaBaseDTO): boolean => {
|
||||
return !!(<PhotoDTO>media).metadata.positionData &&
|
||||
!!((<PhotoDTO>media).metadata.positionData.city ||
|
||||
(<PhotoDTO>media).metadata.positionData.state ||
|
||||
@ -38,11 +46,11 @@ export module MediaDTO {
|
||||
(<PhotoDTO>media).metadata.positionData.GPSData.longitude));
|
||||
};
|
||||
|
||||
export const isPhoto = (media: FileDTO): boolean => {
|
||||
export const isPhoto = (media: FileBaseDTO): boolean => {
|
||||
return !MediaDTO.isVideo(media);
|
||||
};
|
||||
|
||||
export const isVideo = (media: FileDTO): boolean => {
|
||||
export const isVideo = (media: FileBaseDTO): boolean => {
|
||||
const lower = media.name.toLowerCase();
|
||||
for (const ext of SupportedFormats.WithDots.Videos) {
|
||||
if (lower.endsWith(ext)) {
|
||||
@ -62,7 +70,7 @@ export module MediaDTO {
|
||||
return false;
|
||||
};
|
||||
|
||||
export const isVideoTranscodingNeeded = (media: FileDTO): boolean => {
|
||||
export const isVideoTranscodingNeeded = (media: FileBaseDTO): boolean => {
|
||||
const lower = media.name.toLowerCase();
|
||||
for (const ext of SupportedFormats.WithDots.TranscodeNeed.Videos) {
|
||||
if (lower.endsWith(ext)) {
|
||||
@ -73,7 +81,7 @@ export module MediaDTO {
|
||||
};
|
||||
|
||||
|
||||
export const calcAspectRatio = (photo: MediaDTO): number => {
|
||||
export const calcAspectRatio = (photo: MediaBaseDTO): number => {
|
||||
return photo.metadata.size.width / photo.metadata.size.height;
|
||||
};
|
||||
}
|
||||
|
@ -1,8 +1,15 @@
|
||||
import {DirectoryDTO} from './DirectoryDTO';
|
||||
import {DirectoryBaseDTO, DirectoryDTO} from './DirectoryDTO';
|
||||
import {OrientationTypes} from 'ts-exif-parser';
|
||||
import {MediaDimension, MediaDTO, MediaMetadata} from './MediaDTO';
|
||||
import {MediaBaseDTO, MediaDimension, MediaDTO, MediaMetadata} from './MediaDTO';
|
||||
|
||||
export interface PhotoDTO extends MediaDTO {
|
||||
export interface PreviewPhotoDTO extends MediaBaseDTO {
|
||||
name: string;
|
||||
directory: DirectoryBaseDTO;
|
||||
readyThumbnails: Array<number>;
|
||||
readyIcon: boolean;
|
||||
}
|
||||
|
||||
export interface PhotoDTO extends PreviewPhotoDTO, MediaDTO {
|
||||
id: number;
|
||||
name: string;
|
||||
directory: DirectoryDTO;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ShareService} from '../ui/gallery/share.service';
|
||||
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {QueryParams} from '../../../common/QueryParams';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
import {GalleryService} from '../ui/gallery/gallery.service';
|
||||
@ -15,7 +15,7 @@ export class QueryService {
|
||||
private galleryService: GalleryService) {
|
||||
}
|
||||
|
||||
getMediaStringId(media: MediaDTO): string {
|
||||
getMediaStringId(media: MediaBaseDTO): string {
|
||||
if (this.galleryService.isSearchResult()) {
|
||||
return Utils.concatUrls(media.directory.path, media.directory.name, media.name);
|
||||
} else {
|
||||
@ -23,7 +23,7 @@ export class QueryService {
|
||||
}
|
||||
}
|
||||
|
||||
getParams(media?: MediaDTO): { [key: string]: string } {
|
||||
getParams(media?: MediaBaseDTO): { [key: string]: string } {
|
||||
const query: { [key: string]: string } = {};
|
||||
if (media) {
|
||||
query[QueryParams.gallery.photo] = this.getMediaStringId(media);
|
||||
|
@ -1,14 +1,14 @@
|
||||
import {Utils} from '../../../../common/Utils';
|
||||
import {MediaIcon} from './MediaIcon';
|
||||
import {Config} from '../../../../common/config/public/Config';
|
||||
import {MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
|
||||
export class Media extends MediaIcon {
|
||||
|
||||
static readonly sortedThumbnailSizes = Config.Client.Media.Thumbnail.thumbnailSizes
|
||||
.sort((a, b) => a - b);
|
||||
|
||||
constructor(media: MediaDTO, public renderWidth: number, public renderHeight: number) {
|
||||
constructor(media: MediaBaseDTO, public renderWidth: number, public renderHeight: number) {
|
||||
super(media);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
import {Utils} from '../../../../common/Utils';
|
||||
import {Config} from '../../../../common/config/public/Config';
|
||||
import {MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
|
||||
export class MediaIcon {
|
||||
|
||||
|
||||
protected replacementSizeCache: number | boolean = false;
|
||||
|
||||
constructor(public media: MediaDTO) {
|
||||
constructor(public media: MediaBaseDTO) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import {Utils} from '../../../../common/Utils';
|
||||
import {Config} from '../../../../common/config/public/Config';
|
||||
import {IAutoCompleteItem} from '../../../../common/entities/AutoCompleteItem';
|
||||
import {SearchResultDTO} from '../../../../common/entities/SearchResultDTO';
|
||||
import {MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
import {SortingMethods} from '../../../../common/entities/SortingMethods';
|
||||
import {VersionService} from '../../model/version.service';
|
||||
import {SearchQueryDTO, SearchQueryTypes} from '../../../../common/entities/SearchQueryDTO';
|
||||
@ -193,7 +193,7 @@ export class GalleryCacheService {
|
||||
if (value != null) {
|
||||
const directory: DirectoryDTO = JSON.parse(value);
|
||||
|
||||
DirectoryDTO.addReferences(directory);
|
||||
DirectoryDTO.unpackDirectory(directory);
|
||||
return directory;
|
||||
}
|
||||
} catch (e) {
|
||||
@ -231,7 +231,7 @@ export class GalleryCacheService {
|
||||
* Update media state at cache too (Eg.: thumbnail rendered)
|
||||
* @param media
|
||||
*/
|
||||
public mediaUpdated(media: MediaDTO): void {
|
||||
public mediaUpdated(media: MediaBaseDTO): void {
|
||||
|
||||
if (Config.Client.Other.enableCache === false) {
|
||||
return;
|
||||
|
@ -7,6 +7,7 @@ import {Media} from '../../Media';
|
||||
import {Thumbnail, ThumbnailManagerService} from '../../thumbnailManager.service';
|
||||
import {QueryService} from '../../../../model/query.service';
|
||||
import {MediaDTO} from '../../../../../../common/entities/MediaDTO';
|
||||
import {PreviewPhotoDTO} from '../../../../../../common/entities/PhotoDTO';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -27,7 +28,7 @@ export class GalleryDirectoryComponent implements OnInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
public get SamplePhoto(): MediaDTO {
|
||||
public get SamplePhoto(): PreviewPhotoDTO {
|
||||
return this.directory.preview;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ export class GalleryService {
|
||||
return;
|
||||
}
|
||||
|
||||
DirectoryDTO.addReferences(<DirectoryDTO>cw.directory);
|
||||
DirectoryDTO.unpackDirectory(<DirectoryDTO>cw.directory);
|
||||
|
||||
this.lastDirectory = <DirectoryDTO>cw.directory;
|
||||
this.setContent(cw);
|
||||
|
@ -9,7 +9,7 @@ import {Subscription} from 'rxjs';
|
||||
import {ActivatedRoute, Params, Router} from '@angular/router';
|
||||
import {PageHelper} from '../../../model/page.helper';
|
||||
import {QueryService} from '../../../model/query.service';
|
||||
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTO} from '../../../../../common/entities/MediaDTO';
|
||||
import {QueryParams} from '../../../../../common/QueryParams';
|
||||
import {GalleryService} from '../gallery.service';
|
||||
import {PhotoDTO} from '../../../../../common/entities/PhotoDTO';
|
||||
@ -184,7 +184,7 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
public showLigthbox(photo: MediaDTO) {
|
||||
public showLigthbox(photo: MediaBaseDTO) {
|
||||
if (this.controls) {
|
||||
this.controls.resetZoom();
|
||||
}
|
||||
@ -414,7 +414,7 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
|
||||
|
||||
}
|
||||
|
||||
private findPhotoComponent(media: MediaDTO): GalleryPhotoComponent {
|
||||
private findPhotoComponent(media: MediaBaseDTO): GalleryPhotoComponent {
|
||||
const galleryPhotoComponents = this.gridPhotoQL.toArray();
|
||||
for (let i = 0; i < galleryPhotoComponents.length; i++) {
|
||||
if (galleryPhotoComponents[i].gridMedia.media === media) {
|
||||
@ -424,7 +424,7 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
|
||||
return null;
|
||||
}
|
||||
|
||||
private calcLightBoxPhotoDimension(photo: MediaDTO): Dimension {
|
||||
private calcLightBoxPhotoDimension(photo: MediaBaseDTO): Dimension {
|
||||
let width: number;
|
||||
let height: number;
|
||||
const photoAspect = photo.metadata.size.width / photo.metadata.size.height;
|
||||
|
@ -11,6 +11,7 @@ import {DiskMangerWorker} from '../../src/backend/model/threading/DiskMangerWork
|
||||
import {IndexingManager} from '../../src/backend/model/database/sql/IndexingManager';
|
||||
import {GalleryManager} from '../../src/backend/model/database/sql/GalleryManager';
|
||||
import {Connection} from 'typeorm';
|
||||
import {Utils} from '../../src/common/Utils';
|
||||
|
||||
declare let describe: any;
|
||||
const savedDescribe = describe;
|
||||
@ -33,9 +34,10 @@ class GalleryManagerTest extends GalleryManager {
|
||||
}
|
||||
}
|
||||
|
||||
export class SQLTestHelper {
|
||||
export class DBTestHelper {
|
||||
|
||||
static enable = {
|
||||
memory: false,
|
||||
sqlite: true,
|
||||
mysql: process.env.TEST_MYSQL !== 'false'
|
||||
};
|
||||
@ -46,23 +48,39 @@ export class SQLTestHelper {
|
||||
this.tempDir = path.join(__dirname, './tmp');
|
||||
}
|
||||
|
||||
static describe(name: string, tests: (helper?: SQLTestHelper) => void) {
|
||||
savedDescribe(name, async () => {
|
||||
if (SQLTestHelper.enable.sqlite) {
|
||||
const helper = new SQLTestHelper(ServerConfig.DatabaseType.sqlite);
|
||||
savedDescribe('sqlite', () => {
|
||||
return tests(helper);
|
||||
});
|
||||
}
|
||||
if (SQLTestHelper.enable.mysql) {
|
||||
const helper = new SQLTestHelper(ServerConfig.DatabaseType.mysql);
|
||||
savedDescribe('mysql', function () {
|
||||
this.timeout(99999999);
|
||||
// @ts-ignore
|
||||
return tests(helper);
|
||||
});
|
||||
}
|
||||
});
|
||||
static describe(settingsOverride: {
|
||||
memory?: boolean;
|
||||
sqlite?: boolean;
|
||||
mysql?: boolean;
|
||||
} = {}) {
|
||||
const settings = Utils.clone(DBTestHelper.enable);
|
||||
for (const key of Object.keys(settingsOverride)) {
|
||||
(<any>settings)[key] = (<any>settingsOverride)[key];
|
||||
}
|
||||
return (name: string, tests: (helper?: DBTestHelper) => void) => {
|
||||
savedDescribe(name, async () => {
|
||||
if (settings.sqlite) {
|
||||
const helper = new DBTestHelper(ServerConfig.DatabaseType.sqlite);
|
||||
savedDescribe('sqlite', () => {
|
||||
return tests(helper);
|
||||
});
|
||||
}
|
||||
if (settings.mysql) {
|
||||
const helper = new DBTestHelper(ServerConfig.DatabaseType.mysql);
|
||||
savedDescribe('mysql', function () {
|
||||
this.timeout(99999999); // hint for the test environment
|
||||
// @ts-ignore
|
||||
return tests(helper);
|
||||
});
|
||||
}
|
||||
if (settings.memory) {
|
||||
const helper = new DBTestHelper(ServerConfig.DatabaseType.memory);
|
||||
savedDescribe('memory', () => {
|
||||
return tests(helper);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static async persistTestDir(directory: DirectoryDTO): Promise<DirectoryEntity> {
|
||||
@ -103,7 +121,7 @@ export class SQLTestHelper {
|
||||
public async initDB() {
|
||||
if (this.dbType === ServerConfig.DatabaseType.sqlite) {
|
||||
await this.initSQLite();
|
||||
} else {
|
||||
} else if (this.dbType === ServerConfig.DatabaseType.mysql) {
|
||||
await this.initMySQL();
|
||||
}
|
||||
}
|
||||
@ -112,8 +130,10 @@ export class SQLTestHelper {
|
||||
public async clearDB() {
|
||||
if (this.dbType === ServerConfig.DatabaseType.sqlite) {
|
||||
await this.clearUpSQLite();
|
||||
} else {
|
||||
} else if (this.dbType === ServerConfig.DatabaseType.mysql) {
|
||||
await this.clearUpMysql();
|
||||
} else if (this.dbType === ServerConfig.DatabaseType.memory) {
|
||||
await this.clearUpMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +153,8 @@ export class SQLTestHelper {
|
||||
}
|
||||
|
||||
private async resetSQLite() {
|
||||
await SQLConnection.close();
|
||||
await ObjectManagers.reset();
|
||||
// await SQLConnection.close();
|
||||
await fs.promises.rmdir(this.tempDir, {recursive: true});
|
||||
}
|
||||
|
||||
@ -157,4 +178,8 @@ export class SQLTestHelper {
|
||||
private async clearUpSQLite() {
|
||||
return this.resetSQLite();
|
||||
}
|
||||
|
||||
private async clearUpMemory() {
|
||||
return this.resetSQLite();
|
||||
}
|
||||
}
|
@ -3,10 +3,11 @@ import {Server} from '../../../../src/backend/server';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import {expect} from 'chai';
|
||||
import {SQLConnection} from '../../../../src/backend/model/database/sql/SQLConnection';
|
||||
import {SuperAgentStatic} from 'superagent';
|
||||
import {ProjectPath} from '../../../../src/backend/ProjectPath';
|
||||
import {DBTestHelper} from '../../DBTestHelper';
|
||||
import {ServerConfig} from '../../../../src/common/config/private/PrivateConfig';
|
||||
import ReIndexingSensitivity = ServerConfig.ReIndexingSensitivity;
|
||||
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
@ -15,32 +16,73 @@ const chaiHttp = require('chai-http');
|
||||
const should = chai.should();
|
||||
chai.use(chaiHttp);
|
||||
|
||||
describe('GalleryRouter', () => {
|
||||
// to help WebStorm to handle the test cases
|
||||
declare let describe: any;
|
||||
declare const after: any;
|
||||
declare const it: any;
|
||||
const tmpDescribe = describe;
|
||||
describe = DBTestHelper.describe({memory: true});
|
||||
|
||||
describe('GalleryRouter', (sqlHelper: DBTestHelper) => {
|
||||
describe = tmpDescribe;
|
||||
|
||||
const tempDir = path.join(__dirname, '../../tmp');
|
||||
let server: Server;
|
||||
const setUp = async () => {
|
||||
await sqlHelper.initDB();
|
||||
await fs.promises.rmdir(tempDir, {recursive: true});
|
||||
Config.Client.authenticationRequired = false;
|
||||
Config.Server.Threading.enabled = false;
|
||||
Config.Client.Media.Video.enabled = true;
|
||||
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
|
||||
Config.Server.Database.dbFolder = tempDir;
|
||||
Config.Server.Media.folder = path.join(__dirname, '../../assets');
|
||||
Config.Server.Media.tempFolder = path.join(__dirname, '../../tmp');
|
||||
ProjectPath.reset();
|
||||
ProjectPath.ImageFolder = path.join(__dirname, '../../assets');
|
||||
ProjectPath.TempFolder = tempDir;
|
||||
// ProjectPath.ImageFolder = path.join(__dirname, '../../assets');
|
||||
// ProjectPath.TempFolder = tempDir;
|
||||
|
||||
server = new Server();
|
||||
await server.onStarted.wait();
|
||||
|
||||
};
|
||||
const tearDown = async () => {
|
||||
await SQLConnection.close();
|
||||
await fs.promises.rmdir(tempDir, {recursive: true});
|
||||
await sqlHelper.clearDB();
|
||||
};
|
||||
|
||||
|
||||
describe('/GET /api/gallery/content/video.mp4/bestFit', () => {
|
||||
describe('/GET /api/gallery/content/', async () => {
|
||||
|
||||
beforeEach(setUp);
|
||||
afterEach(tearDown);
|
||||
|
||||
it('should load gallery', async () => {
|
||||
const result = await (chai.request(server.App) as SuperAgentStatic)
|
||||
.get('/api/gallery/content/');
|
||||
|
||||
(result.should as any).have.status(200);
|
||||
expect(result.body.error).to.be.equal(null);
|
||||
expect(result.body.result).to.not.be.equal(null);
|
||||
expect(result.body.result.directory).to.not.be.equal(null);
|
||||
console.log(result.body.result.directory);
|
||||
});
|
||||
|
||||
it('should load gallery twice (to force loading form db)', async () => {
|
||||
Config.Server.Indexing.reIndexingSensitivity = ReIndexingSensitivity.low;
|
||||
const _ = await (chai.request(server.App) as SuperAgentStatic)
|
||||
.get('/api/gallery/content/orientation');
|
||||
|
||||
const result = await (chai.request(server.App) as SuperAgentStatic)
|
||||
.get('/api/gallery/content/orientation');
|
||||
|
||||
(result.should as any).have.status(200);
|
||||
expect(result.body.error).to.be.equal(null);
|
||||
expect(result.body.result).to.not.be.equal(null);
|
||||
expect(result.body.result.directory).to.not.be.equal(null);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('/GET /api/gallery/content/video.mp4/bestFit', async () => {
|
||||
|
||||
beforeEach(setUp);
|
||||
afterEach(tearDown);
|
||||
|
@ -1,13 +1,13 @@
|
||||
import {SQLTestHelper} from '../../../SQLTestHelper';
|
||||
import {DBTestHelper} from '../../../DBTestHelper';
|
||||
import {GalleryManager} from '../../../../../src/backend/model/database/sql/GalleryManager';
|
||||
|
||||
|
||||
// to help WebStorm to handle the test cases
|
||||
declare let describe: any;
|
||||
declare const after: any;
|
||||
describe = SQLTestHelper.describe;
|
||||
describe = DBTestHelper.describe();
|
||||
|
||||
describe('GalleryManager', (sqlHelper: SQLTestHelper) => {
|
||||
describe('GalleryManager', (sqlHelper: DBTestHelper) => {
|
||||
|
||||
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ import {FileDTO} from '../../../../../src/common/entities/FileDTO';
|
||||
import {IndexingManager} from '../../../../../src/backend/model/database/sql/IndexingManager';
|
||||
import {ObjectManagers} from '../../../../../src/backend/model/ObjectManagers';
|
||||
import {PersonManager} from '../../../../../src/backend/model/database/sql/PersonManager';
|
||||
import {SQLTestHelper} from '../../../SQLTestHelper';
|
||||
import {DBTestHelper} from '../../../DBTestHelper';
|
||||
import {VersionManager} from '../../../../../src/backend/model/database/sql/VersionManager';
|
||||
import {DiskMangerWorker} from '../../../../../src/backend/model/threading/DiskMangerWorker';
|
||||
import {ServerConfig} from '../../../../../src/common/config/private/PrivateConfig';
|
||||
@ -52,9 +52,9 @@ class IndexingManagerTest extends IndexingManager {
|
||||
declare let describe: any;
|
||||
declare const after: any;
|
||||
declare const it: any;
|
||||
describe = SQLTestHelper.describe;
|
||||
describe = DBTestHelper.describe();
|
||||
|
||||
describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
describe('IndexingManager', (sqlHelper: DBTestHelper) => {
|
||||
|
||||
|
||||
beforeEach(async () => {
|
||||
@ -112,14 +112,14 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
p1.name = 'test.jpg';
|
||||
p2.name = 'Test.jpg';
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
.to.deep.equal(Utils.clone(Utils.removeNullOrEmptyObj(parent)));
|
||||
@ -130,21 +130,21 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const gm = new GalleryManagerTest();
|
||||
const im = new IndexingManagerTest();
|
||||
|
||||
const parent = TestHelper.getRandomizedDirectoryEntry();
|
||||
const parent = TestHelper.getRandomizedDirectoryEntry(null, 'parent');
|
||||
const subDir1 = TestHelper.getRandomizedDirectoryEntry(parent, 'subDir');
|
||||
const p1 = TestHelper.getRandomizedPhotoEntry(subDir1, 'subPhoto1', 0);
|
||||
const subDir2 = TestHelper.getRandomizedDirectoryEntry(parent, 'SUBDIR');
|
||||
const p2 = TestHelper.getRandomizedPhotoEntry(subDir2, 'subPhoto2', 0);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir1);
|
||||
setPartial(subDir2);
|
||||
@ -164,9 +164,9 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const p2 = TestHelper.getRandomizedPhotoEntry(subDir2, 'subPhoto2', 0);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent1);
|
||||
DirectoryDTO.packDirectory(parent1);
|
||||
await im.saveToDB(Utils.clone(parent1));
|
||||
DirectoryDTO.removeReferences(parent2);
|
||||
DirectoryDTO.packDirectory(parent2);
|
||||
await im.saveToDB(Utils.clone(parent2));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
@ -174,7 +174,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const selected = await gm.selectParentDir(conn, parent1.name, parent1.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir1);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
@ -184,7 +184,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const selected = await gm.selectParentDir(conn, parent2.name, parent2.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir2);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
@ -199,7 +199,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const selected = await _gm.selectParentDir(conn, dir.name, dir.path);
|
||||
await _gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
return selected;
|
||||
};
|
||||
@ -222,10 +222,10 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
};
|
||||
|
||||
const saveToDBAndCheck = async (dir: DirectoryDTO) => {
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(dir));
|
||||
await checkParent();
|
||||
DirectoryDTO.addReferences(parent);
|
||||
DirectoryDTO.unpackDirectory(parent);
|
||||
};
|
||||
|
||||
await saveToDBAndCheck(parent);
|
||||
@ -262,20 +262,20 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2', 0);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(subDir);
|
||||
DirectoryDTO.packDirectory(subDir);
|
||||
await im.saveToDB(Utils.clone(subDir));
|
||||
|
||||
parent.directories.push(subDir);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
@ -296,20 +296,20 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2', 0);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(subDir);
|
||||
DirectoryDTO.packDirectory(subDir);
|
||||
await im.saveToDB(Utils.clone(subDir));
|
||||
|
||||
parent.directories.push(subDir);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
@ -329,14 +329,14 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2', 0);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
@ -367,14 +367,14 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
p2.metadata.positionData.GPSData.longitude = minFloat;
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
.to.deep.equalInAnyOrder(Utils.clone(Utils.removeNullOrEmptyObj(parent)));
|
||||
@ -387,7 +387,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const p1 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo1');
|
||||
const p2 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo2');
|
||||
const gpx = TestHelper.getRandomizedGPXEntry(parent, 'GPX1');
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
Config.Client.MetaFile.enabled = true;
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
@ -397,7 +397,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
delete parent.metaFile;
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
.to.deep.equalInAnyOrder(Utils.clone(Utils.removeNullOrEmptyObj(parent)));
|
||||
@ -414,13 +414,13 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
subDir.name = 'subDir';
|
||||
const sp1 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto1');
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2');
|
||||
const sp3 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto3');
|
||||
|
||||
DirectoryDTO.removeReferences(subDir);
|
||||
DirectoryDTO.packDirectory(subDir);
|
||||
await im.saveToDB(Utils.clone(subDir));
|
||||
|
||||
const conn = await SQLConnection.getConnection();
|
||||
@ -429,7 +429,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
|
||||
// subDir.isPartial = true;
|
||||
// delete subDir.directories;
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
delete subDir.parent;
|
||||
delete subDir.metaFile;
|
||||
removeIds(selected);
|
||||
@ -452,7 +452,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const sp2 = TestHelper.getRandomizedPhotoEntry(subDir, 'subPhoto2', 1);
|
||||
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
const s1 = im.queueForSave(Utils.clone(parent));
|
||||
const s2 = im.queueForSave(Utils.clone(parent));
|
||||
const s3 = im.queueForSave(Utils.clone(parent));
|
||||
@ -462,9 +462,10 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const selected = await gm.selectParentDir(conn, parent.name, parent.path);
|
||||
await gm.fillParentDir(conn, selected);
|
||||
|
||||
DirectoryDTO.removeReferences(selected);
|
||||
DirectoryDTO.packDirectory(selected);
|
||||
removeIds(selected);
|
||||
setPartial(subDir);
|
||||
parent.directories.forEach(d => delete (<any>d.preview.metadata).faces);
|
||||
delete sp1.metadata.faces;
|
||||
delete sp2.metadata.faces;
|
||||
expect(Utils.clone(Utils.removeNullOrEmptyObj(selected)))
|
||||
@ -478,14 +479,14 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
const im = new IndexingManagerTest();
|
||||
Config.Client.MetaFile.enabled = true;
|
||||
const parent = TestHelper.getRandomizedDirectoryEntry();
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(Utils.clone(parent));
|
||||
const subDir = TestHelper.getRandomizedDirectoryEntry(parent, 'subDir');
|
||||
for (let i = 0; i < 1500; i++) {
|
||||
TestHelper.getRandomizedPhotoEntry(subDir, 'p' + i);
|
||||
}
|
||||
|
||||
DirectoryDTO.removeReferences(parent);
|
||||
DirectoryDTO.packDirectory(parent);
|
||||
await im.saveToDB(subDir);
|
||||
|
||||
|
||||
@ -493,7 +494,7 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => {
|
||||
expect(selected.media.length).to.equal(subDir.media.length);
|
||||
}) as any).timeout(40000);
|
||||
|
||||
SQLTestHelper.savedDescribe('Test listDirectory', () => {
|
||||
DBTestHelper.savedDescribe('Test listDirectory', () => {
|
||||
const statSync = fs.statSync;
|
||||
let dirTime = 0;
|
||||
const indexedTime = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {expect} from 'chai';
|
||||
import {PersonManager} from '../../../../../src/backend/model/database/sql/PersonManager';
|
||||
import {SQLTestHelper} from '../../../SQLTestHelper';
|
||||
import {DBTestHelper} from '../../../DBTestHelper';
|
||||
import {TestHelper} from './TestHelper';
|
||||
import {PhotoDTO} from '../../../../../src/common/entities/PhotoDTO';
|
||||
import {Utils} from '../../../../../src/common/Utils';
|
||||
@ -18,9 +18,9 @@ declare const before: any;
|
||||
declare const it: any;
|
||||
|
||||
|
||||
describe = SQLTestHelper.describe;
|
||||
describe = DBTestHelper.describe();
|
||||
|
||||
describe('PersonManager', (sqlHelper: SQLTestHelper) => {
|
||||
describe('PersonManager', (sqlHelper: DBTestHelper) => {
|
||||
|
||||
|
||||
let dir: DirectoryDTO;
|
||||
@ -41,7 +41,7 @@ describe('PersonManager', (sqlHelper: SQLTestHelper) => {
|
||||
delete pFaceLess.metadata.faces;
|
||||
v = TestHelper.getVideoEntry1(directory);
|
||||
|
||||
dir = await SQLTestHelper.persistTestDir(directory);
|
||||
dir = await DBTestHelper.persistTestDir(directory);
|
||||
p = <any>dir.media.filter(m => m.name === p.name)[0];
|
||||
p2 = <any>dir.media.filter(m => m.name === p2.name)[0];
|
||||
p_faceLess = <any>dir.media[2];
|
||||
|
@ -2,7 +2,7 @@ import {LocationManager} from '../../../../../src/backend/model/database/Locatio
|
||||
import {SearchManager} from '../../../../../src/backend/model/database/sql/SearchManager';
|
||||
import {SearchResultDTO} from '../../../../../src/common/entities/SearchResultDTO';
|
||||
import {Utils} from '../../../../../src/common/Utils';
|
||||
import {SQLTestHelper} from '../../../SQLTestHelper';
|
||||
import {DBTestHelper} from '../../../DBTestHelper';
|
||||
import {
|
||||
ANDSearchQuery,
|
||||
DistanceSearch,
|
||||
@ -44,7 +44,7 @@ declare let describe: any;
|
||||
declare const after: any;
|
||||
declare const before: any;
|
||||
const tmpDescribe = describe;
|
||||
describe = SQLTestHelper.describe; // fake it os IDE plays nicely (recognize the test)
|
||||
describe = DBTestHelper.describe(); // fake it os IDE plays nicely (recognize the test)
|
||||
|
||||
|
||||
class IndexingManagerTest extends IndexingManager {
|
||||
@ -65,7 +65,7 @@ class GalleryManagerTest extends GalleryManager {
|
||||
}
|
||||
}
|
||||
|
||||
describe('SearchManager', (sqlHelper: SQLTestHelper) => {
|
||||
describe('SearchManager', (sqlHelper: DBTestHelper) => {
|
||||
describe = tmpDescribe;
|
||||
let dir: DirectoryDTO;
|
||||
/**
|
||||
@ -97,7 +97,7 @@ describe('SearchManager', (sqlHelper: SQLTestHelper) => {
|
||||
delete pFaceLess.metadata.faces;
|
||||
v = TestHelper.getVideoEntry1(directory);
|
||||
|
||||
dir = await SQLTestHelper.persistTestDir(directory);
|
||||
dir = await DBTestHelper.persistTestDir(directory);
|
||||
p = <any>dir.media.filter(m => m.name === p.name)[0];
|
||||
p2 = <any>dir.media.filter(m => m.name === p2.name)[0];
|
||||
v = <any>dir.media.filter(m => m.name === v.name)[0];
|
||||
|
@ -4,14 +4,14 @@ import {SharingManager} from '../../../../../src/backend/model/database/sql/Shar
|
||||
import {SharingDTO} from '../../../../../src/common/entities/SharingDTO';
|
||||
import {UserEntity} from '../../../../../src/backend/model/database/sql/enitites/UserEntity';
|
||||
import {UserDTO, UserRoles} from '../../../../../src/common/entities/UserDTO';
|
||||
import {SQLTestHelper} from '../../../SQLTestHelper';
|
||||
import {DBTestHelper} from '../../../DBTestHelper';
|
||||
|
||||
// to help WebStorm to handle the test cases
|
||||
declare let describe: any;
|
||||
declare const after: any;
|
||||
describe = SQLTestHelper.describe;
|
||||
describe = DBTestHelper.describe();
|
||||
|
||||
describe('SharingManager', (sqlHelper: SQLTestHelper) => {
|
||||
describe('SharingManager', (sqlHelper: DBTestHelper) => {
|
||||
|
||||
|
||||
let creator: UserDTO = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user