(filepath: string)
| 68 | } |
| 69 | |
| 70 | async readProtectedFile(filepath: string): Promise<string> { |
| 71 | assertNotTouchingFiles(filepath, 'read'); |
| 72 | if (!encryptionKey) { |
| 73 | encryptionKey = await UI.getWindowsEncryptionPassword(); |
| 74 | } |
| 75 | // Try to decrypt the file |
| 76 | try { |
| 77 | return this.decrypt(read(filepath, 'utf8'), encryptionKey); |
| 78 | } catch (e) { |
| 79 | // If it's a bad password, clear the cached copy and retry |
| 80 | if (e.message.indexOf('bad decrypt') >= -1) { |
| 81 | encryptionKey = null; |
| 82 | return await this.readProtectedFile(filepath); |
| 83 | } |
| 84 | throw e; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | async writeProtectedFile(filepath: string, contents: string) { |
| 89 | assertNotTouchingFiles(filepath, 'write'); |
nothing calls this directly
no test coverage detected