Browse Source

Merge pull request #878 from gre/use-major-version-as-sqlite-prefix

Use libcore major version to prefix the db path
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
960553f818
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/helpers/init-libcore.js

11
src/helpers/init-libcore.js

@ -13,8 +13,9 @@ const fs = require('fs')
const MAX_RANDOM = 2684869021
// increment this number to "clear" sqlite db (it will use another path :D)
const DB_VERSION = 1
const core = new lib.NJSLedgerCore()
const stringVersion = core.getStringVersion()
const sqlitePrefix = `v${stringVersion.split('.')[0]}`
const bytesArrayToString = (bytesArray = []) => Buffer.from(bytesArray).toString()
@ -151,15 +152,15 @@ const instanciateWalletPool = ({ dbPath }) => {
const NJSPathResolver = new lib.NJSPathResolver({
resolveLogFilePath: pathToResolve => {
const hash = pathToResolve.replace(/\//g, '__')
return path.resolve(dbPath, `./log_file_${DB_VERSION}_${hash}`)
return path.resolve(dbPath, `./log_file_${sqlitePrefix}_${hash}`)
},
resolvePreferencesPath: pathToResolve => {
const hash = pathToResolve.replace(/\//g, '__')
return path.resolve(dbPath, `./preferences_${DB_VERSION}_${hash}`)
return path.resolve(dbPath, `./preferences_${sqlitePrefix}_${hash}`)
},
resolveDatabasePath: pathToResolve => {
const hash = pathToResolve.replace(/\//g, '__')
return path.resolve(dbPath, `./database_${DB_VERSION}_${hash}`)
return path.resolve(dbPath, `./database_${sqlitePrefix}_${hash}`)
},
})

Loading…
Cancel
Save