This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-node-casbin.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ab9840  chore: fix bug in built-in file adapter
2ab9840 is described below

commit 2ab984050452eb885b3296d2be218dfe3c35a690
Author: Yang Luo <[email protected]>
AuthorDate: Sat Apr 25 16:17:30 2026 +0800

    chore: fix bug in built-in file adapter
---
 src/persist/defaultFilteredAdapter.ts |  3 +--
 src/persist/fileAdapter.ts            | 34 ++++++++++++++++------------------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/persist/defaultFilteredAdapter.ts 
b/src/persist/defaultFilteredAdapter.ts
index c00bf95..c422f1f 100644
--- a/src/persist/defaultFilteredAdapter.ts
+++ b/src/persist/defaultFilteredAdapter.ts
@@ -57,8 +57,7 @@ export class DefaultFilteredAdapter extends FileAdapter 
implements FilteredAdapt
     if (this.filtered) {
       throw new Error('cannot save a filtered policy');
     }
-    await super.savePolicy(model);
-    return true;
+    return super.savePolicy(model);
   }
 
   private static filterLine(line: string, filter: Filter): boolean {
diff --git a/src/persist/fileAdapter.ts b/src/persist/fileAdapter.ts
index b4926a3..bc16738 100644
--- a/src/persist/fileAdapter.ts
+++ b/src/persist/fileAdapter.ts
@@ -53,28 +53,26 @@ export class FileAdapter implements Adapter {
     let result = '';
 
     const pList = model.model.get('p');
-    if (!pList) {
-      return false;
-    }
-    pList.forEach((n) => {
-      n.policy.forEach((m) => {
-        result += n.key + ', ';
-        result += arrayToString(m);
-        result += '\n';
+    if (pList) {
+      pList.forEach((n) => {
+        n.policy.forEach((m) => {
+          result += n.key + ', ';
+          result += arrayToString(m);
+          result += '\n';
+        });
       });
-    });
+    }
 
     const gList = model.model.get('g');
-    if (!gList) {
-      return false;
-    }
-    gList.forEach((n) => {
-      n.policy.forEach((m) => {
-        result += n.key + ', ';
-        result += arrayToString(m.map((element) => this.escapeCsv(element)));
-        result += '\n';
+    if (gList) {
+      gList.forEach((n) => {
+        n.policy.forEach((m) => {
+          result += n.key + ', ';
+          result += arrayToString(m.map((element) => this.escapeCsv(element)));
+          result += '\n';
+        });
       });
-    });
+    }
 
     await this.savePolicyFile(result.trim());
     return true;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to