X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FAuthorizedTagsCache.ts;h=0f702047702ce5cc92890f28679a9cafddacf1fc;hb=90293abb1042312652c22f8b8c468d99ec080c71;hp=4a9da4ce67f3bfa6e0ca699395f971d1a42712fc;hpb=9d7484a4667898757b7c23be3dec7458c337cb84;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AuthorizedTagsCache.ts b/src/charging-station/AuthorizedTagsCache.ts index 4a9da4ce..0f702047 100644 --- a/src/charging-station/AuthorizedTagsCache.ts +++ b/src/charging-station/AuthorizedTagsCache.ts @@ -1,8 +1,9 @@ +import fs from 'fs'; + import { FileType } from '../types/FileType'; import FileUtils from '../utils/FileUtils'; -import Utils from '../utils/Utils'; -import fs from 'fs'; import logger from '../utils/Logger'; +import Utils from '../utils/Utils'; export default class AuthorizedTagsCache { private static instance: AuthorizedTagsCache | null = null; @@ -15,17 +16,17 @@ export default class AuthorizedTagsCache { } public static getInstance(): AuthorizedTagsCache { - if (!AuthorizedTagsCache.instance) { + if (AuthorizedTagsCache.instance === null) { AuthorizedTagsCache.instance = new AuthorizedTagsCache(); } return AuthorizedTagsCache.instance; } public getAuthorizedTags(file: string): string[] { - if (!this.hasTags(file)) { + if (this.hasTags(file) === false) { this.setTags(file, this.getAuthorizedTagsFromFile(file)); // Monitor authorization file - !this.FSWatchers.has(file) && + this.FSWatchers.has(file) === false && this.FSWatchers.set( file, FileUtils.watchJsonFile( @@ -63,6 +64,10 @@ export default class AuthorizedTagsCache { return this.getTags(file); } + public deleteAuthorizedTags(file: string): boolean { + return this.deleteTags(file); + } + private hasTags(file: string): boolean { return this.tagsCaches.has(file); }