-
Notifications
You must be signed in to change notification settings - Fork 299
[LW-12241] Update index.ts to cater for the cleardown of ledger state if not alr… #3276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
b537d6d
4e7f3b0
41ccdb2
d7cbcdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||
import os from 'os'; | ||||||
import path from 'path'; | ||||||
import * as fs from 'fs'; | ||||||
import { app, dialog, BrowserWindow, screen, shell } from 'electron'; | ||||||
import type { Event } from 'electron'; | ||||||
import EventEmitter from 'events'; | ||||||
|
@@ -24,6 +25,7 @@ | |||||
RTS_FLAGS, | ||||||
stateDirectoryPath, | ||||||
} from './config'; | ||||||
|
||||||
import { setupCardanoNode } from './cardano/setup'; | ||||||
import { CardanoNode } from './cardano/CardanoNode'; | ||||||
import { safeExitWithCode } from './utils/safeExitWithCode'; | ||||||
|
@@ -133,8 +135,50 @@ | |||||
await safeExit(); | ||||||
}; | ||||||
|
||||||
const clearLedger = async () => { | ||||||
const flagFileShortName = 'has_upgraded_to_pv_10'; | ||||||
const chainLedgerDir = 'chain/ledger'; | ||||||
|
||||||
const flagFileLongName = path.join( | ||||||
launcherConfig.stateDir, | ||||||
flagFileShortName | ||||||
); | ||||||
|
||||||
// Check if the flag file exists | ||||||
if (fs.existsSync(flagFileLongName)) { | ||||||
logger.log(`${flagFileLongName} found. NoHskpg.`); | ||||||
} else { | ||||||
try { | ||||||
const chainLedgerLongName = path.join( | ||||||
launcherConfig.stateDir, | ||||||
chainLedgerDir | ||||||
); | ||||||
|
||||||
const files = fs.readdirSync(chainLedgerLongName); | ||||||
|
||||||
for (const file of files) { | ||||||
// DelIterator | ||||||
const filePath = path.join(chainLedgerLongName, file); | ||||||
if (fs.lstatSync(filePath).isFile()) { | ||||||
// ?it's a file | ||||||
fs.unlinkSync(filePath); | ||||||
console.log(`HskpgDone: ${filePath}`); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
|
||||||
// Create v10-upgraded completed marker | ||||||
fs.writeFileSync(flagFileLongName, 'HskpgNwFlag'); | ||||||
} catch (err) { | ||||||
console.error(`Error removing files: ${err}`); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have applied those changes and committed |
||||||
} | ||||||
} | ||||||
}; | ||||||
|
||||||
const onAppReady = async () => { | ||||||
setupLogging(); | ||||||
|
||||||
await clearLedger(); | ||||||
|
||||||
await logUsedVersion( | ||||||
environment.version, | ||||||
path.join(pubLogsFolderPath, 'Daedalus-versions.json') | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there is no
log
method on logger. Please useinfo
instead.