File tree Expand file tree Collapse file tree
sync/dao/db.backup.manager Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ const {
4242const appDeps = require ( './loc.api/di/app.deps' )
4343const TYPES = require ( './loc.api/di/types' )
4444const fwDataValidator = require ( './loc.api/data-validator' )
45+ const { isBfxApiStaging } = require ( './loc.api/helpers' )
4546
4647class WrkReportFrameWorkApi extends WrkReportServiceApi {
4748 loadCoreDeps ( ...args ) {
@@ -128,8 +129,12 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi {
128129 syncMode,
129130 dbDriver,
130131 verboseSql,
131- dbPathAbsolute
132+ dbPathAbsolute,
133+ restUrl
132134 } = this . conf [ this . group ]
135+ const stagingDbLabel = isBfxApiStaging ( restUrl )
136+ ? '-staging'
137+ : ''
133138 const facs = [ ]
134139
135140 if ( syncMode ) {
@@ -147,7 +152,7 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi {
147152 'm0' ,
148153 'm0' ,
149154 {
150- name : ' sync' ,
155+ name : ` sync${ stagingDbLabel } ` ,
151156 dbPathAbsolute,
152157 workerPathAbsolute,
153158 verbose : verboseSql ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const {
1818 getAuthFromSubAccountAuth,
1919 getSubAccountAuthFromAuth
2020} = require ( './sub-account-auth' )
21+ const isBfxApiStaging = require ( './is-bfx-api-staging' )
2122
2223module . exports = {
2324 checkParamsAuth,
@@ -33,5 +34,6 @@ module.exports = {
3334 sumAllObjectsNumbers,
3435 pickAllLowerObjectsNumbers,
3536 sumArrayVolumes,
36- pushLargeArr
37+ pushLargeArr,
38+ isBfxApiStaging
3739}
Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ const pattern = / ( s t a g i n g ) | ( t e s t ) / i
4+
5+ module . exports = ( restUrl ) => {
6+ return ! ! (
7+ restUrl &&
8+ typeof restUrl === 'string' &&
9+ pattern . test ( restUrl )
10+ )
11+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ const path = require('path')
66const moment = require ( 'moment' )
77const { orderBy } = require ( 'lodash' )
88
9+ const { isBfxApiStaging } = require ( '../../../helpers' )
10+
911const { decorateInjectable } = require ( '../../../di/utils' )
1012
1113const depsTypes = ( TYPES ) => [
@@ -39,7 +41,10 @@ class DBBackupManager {
3941 this . conf . dbPathAbsolute ,
4042 'backups'
4143 )
42- this . _dbFileName = 'db-sqlite_sync_m0.db'
44+ const stagingDbLabel = isBfxApiStaging ( this . conf . restUrl )
45+ ? '-staging'
46+ : ''
47+ this . _dbFileName = `db-sqlite_sync${ stagingDbLabel } _m0.db`
4348 this . _dbDestination = path . join (
4449 this . conf . dbPathAbsolute ,
4550 this . _dbFileName
You can’t perform that action at this time.
0 commit comments