File tree Expand file tree Collapse file tree 1 file changed +9
-16
lines changed
packages/neuron-wallet/src/database/chain Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change 1- import fs from 'fs'
2- import path from 'path'
3- import env from 'env'
1+ import { getConnection } from 'typeorm'
2+ import InputEntity from './entities/input'
3+ import OutputEntity from './entities/output'
4+ import TransactionEntity from './entities/transaction'
5+ import SyncInfoEntity from './entities/sync-info'
46
57// Clean local sqlite storage
68export default class ChainCleaner {
7- // Delete all sqlite files under cells folder.
8- // It doesn't handle error or throw exception when deleting fails.
9- public static clean ( ) {
10- const folder = path . join ( env . fileBasePath , 'cells' )
11- fs . readdir ( folder , ( err , files ) => {
12- if ( err ) {
13- return
14- }
15-
16- for ( const file of files . filter ( f => { return path . extname ( f ) === '.sqlite' } ) ) {
17- fs . unlink ( path . join ( folder , file ) , ( ) => { } )
18- }
19- } )
9+ public static async clean ( ) {
10+ for ( const entity of [ InputEntity , OutputEntity , TransactionEntity , SyncInfoEntity ] ) {
11+ await getConnection ( ) . getRepository ( entity ) . clear ( )
12+ }
2013 }
2114}
You can’t perform that action at this time.
0 commit comments