Skip to content

Commit

Permalink
Merge pull request #113 from bitfinexcom/beta
Browse files Browse the repository at this point in the history
Release version 3.5.5
  • Loading branch information
ezewer authored Aug 30, 2021
2 parents c126d87 + 3fd122f commit 1321acc
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-report-electron",
"version": "3.5.4",
"version": "3.5.5",
"repository": "https://github.com/bitfinexcom/bfx-report-electron",
"description": "Reporting tool",
"author": "bitfinex.com",
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ let isMigrationsError = false
}
const handlerErr = (err) => {
ipc.removeListener('message', handlerMess)

reject(err)
}

ipc.once('error', handlerErr)
ipc.on('message', handlerMess)
})
Expand Down
7 changes: 6 additions & 1 deletion src/change-reports-folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const electron = require('electron')

const { CSV_PATH_VERSION } = require('./const')

const {
InvalidFilePathError,
ReportsFolderChangingError
Expand Down Expand Up @@ -51,7 +53,10 @@ module.exports = ({ pathToUserDocuments }) => {

await pauseApp()
const isSaved = await getConfigsKeeperByName('main')
.saveConfigs({ pathToUserCsv: filePaths[0] })
.saveConfigs({
csvPathVersion: CSV_PATH_VERSION,
pathToUserCsv: filePaths[0]
})

if (!isSaved) {
throw new ReportsFolderChangingError()
Expand Down
4 changes: 3 additions & 1 deletion src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const DB_FILE_NAME = 'db-sqlite_sync_m0.db'
const DB_SHM_FILE_NAME = `${DB_FILE_NAME}-shm`
const DB_WAL_FILE_NAME = `${DB_FILE_NAME}-wal`
const SECRET_KEY_FILE_NAME = 'secret-key'
const CSV_PATH_VERSION = 1

module.exports = {
CONFIGS_FILE_NAME,
DEFAULT_ARCHIVE_DB_FILE_NAME,
DB_FILE_NAME,
DB_SHM_FILE_NAME,
DB_WAL_FILE_NAME,
SECRET_KEY_FILE_NAME
SECRET_KEY_FILE_NAME,
CSV_PATH_VERSION
}
2 changes: 1 addition & 1 deletion src/error-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const initLogger = () => {
const error = message.data.join(os.EOL)

// Don't open a new issue when can't download differentially
// it would fallback to full download
// it would fallback to full download
if (/Cannot download differentially/gi.test(error)) {
return message
}
Expand Down
83 changes: 58 additions & 25 deletions src/initialize-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const { app } = require('electron')
const path = require('path')

const { CSV_PATH_VERSION } = require('./const')

const triggerElectronLoad = require('./trigger-electron-load')
const wins = require('./windows')
const ipcs = require('./ipcs')
Expand Down Expand Up @@ -50,6 +52,55 @@ const { rule: schedulerRule } = require(
'../bfx-reports-framework/config/schedule.json'
)

const _resetCsvPath = async (
configsKeeper,
opts = {}
) => {
const {
pathToUserCsv,
isRelativeCsvPath
} = opts

// Need to use a new csv folder path for export
const storedPathToUserCsv = configsKeeper
.getConfigByName('pathToUserCsv')
const csvPathVersion = configsKeeper
.getConfigByName('csvPathVersion')

if (csvPathVersion === CSV_PATH_VERSION) {
return
}
if (
(
isRelativeCsvPath &&
!storedPathToUserCsv.endsWith('csv')
) ||
(
!isRelativeCsvPath &&
!storedPathToUserCsv.endsWith('bitfinex/reports')
) ||
(
!isRelativeCsvPath &&
!path.isAbsolute(storedPathToUserCsv)
) ||
(
isRelativeCsvPath &&
path.isAbsolute(storedPathToUserCsv)
)
) {
await configsKeeper.saveConfigs({
csvPathVersion: CSV_PATH_VERSION,
pathToUserCsv
})

return
}

await configsKeeper.saveConfigs({
csvPathVersion: CSV_PATH_VERSION
})
}

const _ipcMessToPromise = (ipc) => {
return new Promise((resolve, reject) => {
try {
Expand Down Expand Up @@ -101,31 +152,13 @@ module.exports = async () => {
schedulerRule
}
)

// Need to use a new csv folder path for export
const storedPathToUserCsv = configsKeeper
.getConfigByName('pathToUserCsv')

if (
(
isRelativeCsvPath &&
!storedPathToUserCsv.endsWith('csv')
) ||
(
!isRelativeCsvPath &&
!storedPathToUserCsv.endsWith('bitfinex/reports')
) ||
(
!isRelativeCsvPath &&
!path.isAbsolute(storedPathToUserCsv)
) ||
(
isRelativeCsvPath &&
path.isAbsolute(storedPathToUserCsv)
)
) {
await configsKeeper.saveConfigs({ pathToUserCsv })
}
_resetCsvPath(
configsKeeper,
{
pathToUserCsv,
isRelativeCsvPath
}
)

const secretKey = await makeOrReadSecretKey(
{ pathToUserData }
Expand Down

0 comments on commit 1321acc

Please sign in to comment.