mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-27 02:09:16 +02:00
improving date structure update handling
This commit is contained in:
parent
7a322e2afa
commit
16c3a755ee
@ -13,11 +13,11 @@ import {VersionEntity} from './enitites/VersionEntity';
|
||||
import {Logger} from '../../Logger';
|
||||
import {MediaEntity} from './enitites/MediaEntity';
|
||||
import {VideoEntity} from './enitites/VideoEntity';
|
||||
import {DataStructureVersion} from '../../../common/DataStructureVersion';
|
||||
|
||||
|
||||
export class SQLConnection {
|
||||
|
||||
private static VERSION = 2;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
@ -92,14 +92,14 @@ export class SQLConnection {
|
||||
version = await connection.getRepository(VersionEntity).findOne();
|
||||
} catch (ex) {
|
||||
}
|
||||
if (version && version.version === SQLConnection.VERSION) {
|
||||
if (version && version.version === DataStructureVersion) {
|
||||
return;
|
||||
}
|
||||
Logger.info('Updating database scheme');
|
||||
if (!version) {
|
||||
version = new VersionEntity();
|
||||
}
|
||||
version.version = SQLConnection.VERSION;
|
||||
version.version = DataStructureVersion;
|
||||
|
||||
|
||||
await connection.dropDatabase();
|
||||
|
1
common/DataStructureVersion.ts
Normal file
1
common/DataStructureVersion.ts
Normal file
@ -0,0 +1 @@
|
||||
export const DataStructureVersion = 2;
|
@ -6,6 +6,7 @@ import {Config} from '../../../common/config/public/Config';
|
||||
import {AutoCompleteItem, SearchTypes} from '../../../common/entities/AutoCompleteItem';
|
||||
import {SearchResultDTO} from '../../../common/entities/SearchResultDTO';
|
||||
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
||||
import {DataStructureVersion} from '../../../common/DataStructureVersion';
|
||||
|
||||
interface CacheItem<T> {
|
||||
timestamp: number;
|
||||
@ -20,6 +21,16 @@ export class GalleryCacheService {
|
||||
private static INSTANT_SEARCH_PREFIX = 'instant_search:';
|
||||
private static SEARCH_PREFIX = 'search:';
|
||||
private static SEARCH_TYPE_PREFIX = ':type:';
|
||||
private static VERSION = 'version';
|
||||
|
||||
constructor() {
|
||||
const version = parseInt(localStorage.getItem(GalleryCacheService.VERSION), 10) || 0;
|
||||
if (version !== DataStructureVersion) {
|
||||
localStorage.clear();
|
||||
localStorage.setItem(GalleryCacheService.VERSION, DataStructureVersion.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public getAutoComplete(text: string): Array<AutoCompleteItem> {
|
||||
|
Loading…
Reference in New Issue
Block a user