Browse Source

plugin-state server: remove /clear and can't remotely remove sticky entries

dsehnal 4 years ago
parent
commit
f752ee5094
1 changed files with 15 additions and 14 deletions
  1. 15 14
      src/servers/plugin-state/index.ts

+ 15 - 14
src/servers/plugin-state/index.ts

@@ -75,6 +75,7 @@ function remove(id: string) {
             i++;
             continue;
         }
+        if (e.isSticky) return;
         try {
             for (let j = i + 1; j < index.length; j++) {
                 index[j - 1] = index[j];
@@ -89,15 +90,15 @@ function remove(id: string) {
     }
 }
 
-function clear() {
-    let index = readIndex();
-    for (const e of index) {
-        try {
-            fs.unlinkSync(path.join(Config.working_folder, e.id + '.json'));
-        } catch { }
-    }
-    writeIndex([]);
-}
+// function clear() {
+//     let index = readIndex();
+//     for (const e of index) {
+//         try {
+//             fs.unlinkSync(path.join(Config.working_folder, e.id + '.json'));
+//         } catch { }
+//     }
+//     writeIndex([]);
+// }
 
 function mapPath(path: string) {
     if (!Config.api_prefix) return path;
@@ -128,11 +129,11 @@ app.get(mapPath(`/get/:id`), (req, res) => {
     });
 });
 
-app.get(mapPath(`/clear`), (req, res) => {
-    clear();
-    res.status(200);
-    res.end();
-});
+// app.get(mapPath(`/clear`), (req, res) => {
+//     clear();
+//     res.status(200);
+//     res.end();
+// });
 
 app.get(mapPath(`/remove/:id`), (req, res) => {
     remove((req.params.id as string || '').toLowerCase());