mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Show also a message box when recovery is not successful
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use babel'
|
||||
|
||||
import {BrowserWindow} from 'electron'
|
||||
import {dialog} from 'electron'
|
||||
import FileRecoveryService from '../../src/main-process/file-recovery-service'
|
||||
import temp from 'temp'
|
||||
import fs from 'fs-plus'
|
||||
@@ -111,6 +111,7 @@ describe("FileRecoveryService", () => {
|
||||
|
||||
let logs = []
|
||||
this.stub(console, 'log', (message) => logs.push(message))
|
||||
this.stub(dialog, 'showMessageBox')
|
||||
|
||||
recoveryService.willSavePath(mockWindow, filePath)
|
||||
recoveryService.didCrashWindow(mockWindow)
|
||||
|
||||
@@ -86,7 +86,6 @@ class AtomApplication
|
||||
@handleEvents()
|
||||
@setupDockMenu()
|
||||
@storageFolder = new StorageFolder(process.env.ATOM_HOME)
|
||||
@fileRecoveryService.start()
|
||||
|
||||
if options.pathsToOpen?.length > 0 or options.urlsToOpen?.length > 0 or options.test
|
||||
@openWithOptions(options)
|
||||
|
||||
@@ -142,15 +142,14 @@ class AtomWindow
|
||||
global.atomApplication.exit(100) if @headless
|
||||
|
||||
@fileRecoveryService.didCrashWindow(this)
|
||||
dialog.showMessageBox @browserWindow,
|
||||
chosen = dialog.showMessageBox @browserWindow,
|
||||
type: 'warning'
|
||||
buttons: ['Close Window', 'Reload', 'Keep It Open']
|
||||
message: 'The editor has crashed'
|
||||
detail: 'Please report this issue to https://github.com/atom/atom',
|
||||
(chosen) =>
|
||||
switch chosen
|
||||
when 0 then @browserWindow.destroy()
|
||||
when 1 then @browserWindow.reload()
|
||||
switch chosen
|
||||
when 0 then @browserWindow.destroy()
|
||||
when 1 then @browserWindow.reload()
|
||||
|
||||
@browserWindow.webContents.on 'will-navigate', (event, url) =>
|
||||
unless url is @browserWindow.webContents.getURL()
|
||||
|
||||
@@ -52,10 +52,12 @@ export default class FileRecoveryService {
|
||||
try {
|
||||
recoveryFile.recoverSync()
|
||||
} catch (error) {
|
||||
console.log(
|
||||
const message = 'A file that Atom was saving could be corrupted'
|
||||
const detail =
|
||||
`There was a crash while saving "${recoveryFile.originalPath}", so this file might be blank or corrupted.\n` +
|
||||
`Atom couldn't recover it automatically, but a recovery file has been saved at: "${recoveryFile.recoveryPath}".`
|
||||
)
|
||||
console.log(detail)
|
||||
dialog.showMessageBox(window.browserWindow, {type: 'info', buttons: ['OK'], message, detail})
|
||||
} finally {
|
||||
this.recoveryFilesByFilePath.delete(recoveryFile.originalPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user