Skip to content

Commit 2ab9840

Browse files
committed
chore: fix bug in built-in file adapter
1 parent 72d0563 commit 2ab9840

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

src/persist/defaultFilteredAdapter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ export class DefaultFilteredAdapter extends FileAdapter implements FilteredAdapt
5757
if (this.filtered) {
5858
throw new Error('cannot save a filtered policy');
5959
}
60-
await super.savePolicy(model);
61-
return true;
60+
return super.savePolicy(model);
6261
}
6362

6463
private static filterLine(line: string, filter: Filter): boolean {

src/persist/fileAdapter.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,26 @@ export class FileAdapter implements Adapter {
5353
let result = '';
5454

5555
const pList = model.model.get('p');
56-
if (!pList) {
57-
return false;
58-
}
59-
pList.forEach((n) => {
60-
n.policy.forEach((m) => {
61-
result += n.key + ', ';
62-
result += arrayToString(m);
63-
result += '\n';
56+
if (pList) {
57+
pList.forEach((n) => {
58+
n.policy.forEach((m) => {
59+
result += n.key + ', ';
60+
result += arrayToString(m);
61+
result += '\n';
62+
});
6463
});
65-
});
64+
}
6665

6766
const gList = model.model.get('g');
68-
if (!gList) {
69-
return false;
70-
}
71-
gList.forEach((n) => {
72-
n.policy.forEach((m) => {
73-
result += n.key + ', ';
74-
result += arrayToString(m.map((element) => this.escapeCsv(element)));
75-
result += '\n';
67+
if (gList) {
68+
gList.forEach((n) => {
69+
n.policy.forEach((m) => {
70+
result += n.key + ', ';
71+
result += arrayToString(m.map((element) => this.escapeCsv(element)));
72+
result += '\n';
73+
});
7674
});
77-
});
75+
}
7876

7977
await this.savePolicyFile(result.trim());
8078
return true;

0 commit comments

Comments
 (0)