Meriadec Pillet
7 years ago
committed by
GitHub
4 changed files with 13 additions and 13 deletions
@ -1,20 +1,21 @@ |
|||||
// @flow
|
// @flow
|
||||
|
|
||||
import { createCommand } from 'helpers/ipc' |
import { createCommand } from 'helpers/ipc' |
||||
import { Observable } from 'rxjs' |
import { fromPromise } from 'rxjs/observable/fromPromise' |
||||
import withLibcore from 'helpers/withLibcore' |
import withLibcore from 'helpers/withLibcore' |
||||
|
import createCustomErrorClass from 'helpers/createCustomErrorClass' |
||||
|
|
||||
|
const HardResetFail = createCustomErrorClass('HardResetFail') |
||||
|
|
||||
const cmd = createCommand('libcoreHardReset', () => |
const cmd = createCommand('libcoreHardReset', () => |
||||
Observable.create(o => { |
fromPromise( |
||||
withLibcore(async core => { |
withLibcore(async core => { |
||||
try { |
const result = await core.getPoolInstance().eraseDataSince(new Date(0)) |
||||
core.getPoolInstance().eraseDataSince(new Date(0)) |
if (result !== core.ERROR_CODE.FUTURE_WAS_SUCCESSFULL) { |
||||
o.complete() |
throw new HardResetFail(`Hard reset fail with ${result} (check core.ERROR_CODE)`) |
||||
} catch (e) { |
|
||||
o.error(e) |
|
||||
} |
} |
||||
}) |
}), |
||||
}), |
), |
||||
) |
) |
||||
|
|
||||
export default cmd |
export default cmd |
||||
|
Loading…
Reference in new issue