Skip to content

Commit

Permalink
Merge pull request #394 from bitfinexcom/staging
Browse files Browse the repository at this point in the history
Release version to master
  • Loading branch information
prdn authored Aug 28, 2024
2 parents 5b90d3c + 0fc54d2 commit 1dcc950
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 160 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",
"version": "4.10.6",
"version": "4.10.7",
"description": "Reporting tool",
"main": "worker.js",
"license": "Apache-2.0",
Expand Down
60 changes: 34 additions & 26 deletions test/helpers/helpers.core.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
'use strict'

const { promisify } = require('util')
const path = require('path')
const fs = require('fs')

const readdir = promisify(fs.readdir)
const unlink = promisify(fs.unlink)
const mkdir = promisify(fs.mkdir)
const {
readdir,
mkdir,
rm
} = require('node:fs/promises')

const rmDB = async (
dir,
exclude = ['.gitkeep'],
isThrownError
exclude = ['.gitkeep']
) => {
try {
const files = await readdir(dir)
const promisesArr = files.map((file) => {
if (exclude.every(exFile => exFile !== file)) {
return unlink(path.join(dir, file))
const files = await readdir(
dir,
{ withFileTypes: true }
)

for (const dirent of files) {
const { name } = dirent

if (
!dirent.isFile() ||
exclude.some((exFile) => exFile === name)
) {
continue
}

return null
})

const res = await Promise.all(promisesArr)

return res
} catch (err) {
if (!isThrownError) {
return
const filePath = path.join(dir, name)
await rm(
filePath,
{
force: true,
maxRetries: 5,
recursive: true,
retryDelay: 200
}
)
}

throw err
} catch (err) {
console.log(err)
}
}

const rmAllFiles = async (dir, exclude) => {
try {
await rmDB(dir, exclude, true)
await rmDB(dir, exclude)
await mkdir(dir, { recursive: true })
} catch (err) {
if (err.syscall === 'scandir') {
await mkdir(dir)
}
console.log(err)
}
}

Expand Down
9 changes: 0 additions & 9 deletions workers/api.service.report.wrk.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ class WrkReportServiceApi extends WrkApi {
loadDIConfig (cont = container) {
const conf = this.conf[this.group]

/**
* @deprecated isAddedUniqueEndingToCsvName
* Keep for back compatibility
*/
conf.isAddedUniqueEndingToReportFileName = (
conf.isAddedUniqueEndingToReportFileName ??
conf.isAddedUniqueEndingToCsvName
)

this.container = cont

diConfig(conf, this.ctx.root)
Expand Down
8 changes: 1 addition & 7 deletions workers/loc.api/generate-report-file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ const _getReportFileStoreStatus = async ({
return {
isSaveLocaly: true,
localReportFolderPath,
remoteReportUrn,

/**
* @deprecated fields
*/
localCsvFolderPath: localReportFolderPath,
remoteCsvUrn: remoteReportUrn
remoteReportUrn
}
}

Expand Down
16 changes: 14 additions & 2 deletions workers/loc.api/helpers/api-errors-testers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const isEAiAgainError = (err) => {
}

const isEConnRefusedError = (err) => {
return /ECONNREFUSED/i.test(_getErrorString(err))
return /(ECONNREFUSED)|(ERR_CONNECTION_REFUSED)/i.test(_getErrorString(err))
}

const isEConnClosedError = (err) => {
return /ERR_CONNECTION_CLOSED/i.test(_getErrorString(err))
}

const isENotFoundError = (err) => {
Expand All @@ -71,6 +75,10 @@ const isTempUnavailableError = (err) => {
return /temporarily_unavailable/i.test(_getErrorString(err))
}

const isBadGatewayError = (err) => {
return /Bad Gateway/i.test(_getErrorString(err))
}

const isForbiddenError = (err) => {
return /forbidden/i.test(_getErrorString(err))
}
Expand All @@ -87,11 +95,13 @@ const isENetError = (err) => (
isNodeFetchTimeoutError(err) ||
isEAiAgainError(err) ||
isEConnRefusedError(err) ||
isEConnClosedError(err) ||
isENotFoundError(err) ||
isESocketTimeoutError(err) ||
isEHostUnreachError(err) ||
isEProtoError(err) ||
isTempUnavailableError(err)
isTempUnavailableError(err) ||
isBadGatewayError(err)
)

module.exports = {
Expand All @@ -106,11 +116,13 @@ module.exports = {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError
Expand Down
10 changes: 10 additions & 0 deletions workers/loc.api/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ const {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError
Expand Down Expand Up @@ -81,8 +86,13 @@ module.exports = {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError,
Expand Down
Loading

0 comments on commit 1dcc950

Please sign in to comment.