X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FIdTagsCache.ts;h=5e0ab0b8f0778c2fbf02333c579657387a5c1d5f;hb=129fdda549b8c7dc7c43ec5893d14a1151ed61a9;hp=5c0a454a05d6615389de331d19b72832bd4724a4;hpb=b3b3f0eb5e187646c6502a9d36939e05c80b5939;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/IdTagsCache.ts b/src/charging-station/IdTagsCache.ts index 5c0a454a..5e0ab0b8 100644 --- a/src/charging-station/IdTagsCache.ts +++ b/src/charging-station/IdTagsCache.ts @@ -7,14 +7,14 @@ import { handleFileException, isNotEmptyString, logPrefix, - // logger, + logger, secureRandom, - // watchJsonFile, + watchJsonFile, } from '../utils'; interface IdTagsCacheValueType { idTags: string[]; - idTagsFileWatcher?: FSWatcher | undefined; + idTagsFileWatcher: FSWatcher | undefined; } export class IdTagsCache { @@ -123,34 +123,33 @@ export class IdTagsCache { private setIdTagsCache(file: string, idTags: string[]) { return this.idTagsCaches.set(file, { idTags, - // FIXME: Disabled until the spurious configuration file change detection is identified - // idTagsFileWatcher: watchJsonFile( - // file, - // FileType.Authorization, - // this.logPrefix(file), - // undefined, - // (event, filename) => { - // if (isNotEmptyString(filename) && event === 'change') { - // try { - // logger.debug( - // `${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`, - // ); - // this.deleteIdTagsCache(file); - // this.deleteIdTagsCacheIndexes(file); - // } catch (error) { - // handleFileException( - // file, - // FileType.Authorization, - // error as NodeJS.ErrnoException, - // this.logPrefix(file), - // { - // throwError: false, - // }, - // ); - // } - // } - // }, - // ), + idTagsFileWatcher: watchJsonFile( + file, + FileType.Authorization, + this.logPrefix(file), + undefined, + (event, filename) => { + if (isNotEmptyString(filename) && event === 'change') { + try { + logger.debug( + `${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`, + ); + this.deleteIdTagsCache(file); + this.deleteIdTagsCacheIndexes(file); + } catch (error) { + handleFileException( + file, + FileType.Authorization, + error as NodeJS.ErrnoException, + this.logPrefix(file), + { + throwError: false, + }, + ); + } + } + }, + ), }); }