()
| 41 | } |
| 42 | |
| 43 | export async function checkAndRestoreITerm2Backup(): Promise<RestoreResult> { |
| 44 | const { inProgress, backupPath } = getIterm2RecoveryInfo() |
| 45 | if (!inProgress) { |
| 46 | return { status: 'no_backup' } |
| 47 | } |
| 48 | |
| 49 | if (!backupPath) { |
| 50 | markITerm2SetupComplete() |
| 51 | return { status: 'no_backup' } |
| 52 | } |
| 53 | |
| 54 | try { |
| 55 | await stat(backupPath) |
| 56 | } catch { |
| 57 | markITerm2SetupComplete() |
| 58 | return { status: 'no_backup' } |
| 59 | } |
| 60 | |
| 61 | try { |
| 62 | await copyFile(backupPath, getITerm2PlistPath()) |
| 63 | |
| 64 | markITerm2SetupComplete() |
| 65 | return { status: 'restored' } |
| 66 | } catch (restoreError) { |
| 67 | logError( |
| 68 | new Error(`Failed to restore iTerm2 settings with: ${restoreError}`), |
| 69 | ) |
| 70 | markITerm2SetupComplete() |
| 71 | return { status: 'failed', backupPath } |
| 72 | } |
| 73 | } |
| 74 |
no test coverage detected