build: bump volta pnpm version
[e-mobility-charging-stations-simulator.git] / src / charging-station / IdTagsCache.ts
index 5c0a454a05d6615389de331d19b72832bd4724a4..5e0ab0b8f0778c2fbf02333c579657387a5c1d5f 100644 (file)
@@ -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,
+                },
+              );
+            }
+          }
+        },
+      ),
     });
   }