Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit a73c707

Browse files
committed
Check if SCB file exists on external storage before reading
1 parent 000d169 commit a73c707

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/action/file-mobile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class FileAction {
103103
}
104104

105105
async readSCBFromExternalStorage() {
106+
const exists = await this._FS.exists(this.scbExternalPath);
107+
if (!exists) return;
106108
return this._FS.readFile(this.scbExternalPath, 'base64');
107109
}
108110
}

test/unit/action/file-mobile.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ describe('Action File Mobile Unit Tests', () => {
132132
});
133133

134134
describe('get readSCBFromExternalStorage()', () => {
135-
it('should get lnd directory', async () => {
135+
it('should read the scb if it exists', async () => {
136+
RNFS.exists.resolves(true);
136137
expect(await file.readSCBFromExternalStorage(), 'to equal', 'some-data');
137138
});
139+
140+
it('should not read the scb if it does not exist', async () => {
141+
RNFS.exists.resolves(false);
142+
expect(await file.readSCBFromExternalStorage(), 'to equal', undefined);
143+
});
138144
});
139145
});

0 commit comments

Comments
 (0)