dobo-extra 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/export-to.js +5 -5
- package/lib/import-from.js +1 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +8 -0
package/lib/export-to.js
CHANGED
|
@@ -7,13 +7,13 @@ import supportedExt from './io-exts.js'
|
|
|
7
7
|
const { DataStream } = scramjet
|
|
8
8
|
|
|
9
9
|
async function getFile (dest, ensureDir) {
|
|
10
|
-
const { importPkg
|
|
10
|
+
const { importPkg } = this.app.bajo
|
|
11
11
|
const { fs } = this.app.lib
|
|
12
12
|
const increment = await importPkg('bajo:add-filename-increment')
|
|
13
13
|
let file
|
|
14
14
|
if (path.isAbsolute(dest)) file = dest
|
|
15
15
|
else {
|
|
16
|
-
file = `${getPluginDataDir(this.ns)}/export/${dest}`
|
|
16
|
+
file = `${this.app.getPluginDataDir(this.ns)}/export/${dest}`
|
|
17
17
|
fs.ensureDirSync(path.dirname(file))
|
|
18
18
|
}
|
|
19
19
|
file = increment(file, { fs: true })
|
|
@@ -37,7 +37,7 @@ async function getData ({ source, filter, count, stream, progressFn, fields }) {
|
|
|
37
37
|
let cnt = count ?? 0
|
|
38
38
|
const { find } = this.app.lib._
|
|
39
39
|
const { recordFind, getSchema } = this.app.dobo
|
|
40
|
-
const { maxLimit,
|
|
40
|
+
const { maxLimit, hardCap } = this.app.dobo.config.default.filter
|
|
41
41
|
filter.limit = maxLimit
|
|
42
42
|
let sort
|
|
43
43
|
const schema = getSchema(source)
|
|
@@ -54,8 +54,8 @@ async function getData ({ source, filter, count, stream, progressFn, fields }) {
|
|
|
54
54
|
const batchStart = new Date()
|
|
55
55
|
const { data, page } = await recordFind(source, filter, { dataOnly: false, fields })
|
|
56
56
|
if (data.length === 0) break
|
|
57
|
-
if (cnt + data.length >
|
|
58
|
-
const sliced = data.slice(0,
|
|
57
|
+
if (cnt + data.length > hardCap) {
|
|
58
|
+
const sliced = data.slice(0, hardCap - cnt)
|
|
59
59
|
await stream.pull(sliced)
|
|
60
60
|
cnt += sliced.length
|
|
61
61
|
if (progressFn) await progressFn.call(this, { batchNo: page, data: sliced, batchStart, batchEnd: new Date() })
|
package/lib/import-from.js
CHANGED
|
@@ -7,7 +7,6 @@ import scramjet from 'scramjet'
|
|
|
7
7
|
const { DataStream } = scramjet
|
|
8
8
|
|
|
9
9
|
async function importFrom (source, dest, { trashOld = true, batch = 1, progressFn, converterFn, useHeader = true, fileType, createOpts = {} } = {}, opts = {}) {
|
|
10
|
-
const { getPluginDataDir } = this.app.bajo
|
|
11
10
|
const { recordCreate } = this.app.dobo
|
|
12
11
|
const { merge } = this.app.lib._
|
|
13
12
|
const { fs } = this.app.lib
|
|
@@ -16,7 +15,7 @@ async function importFrom (source, dest, { trashOld = true, batch = 1, progressF
|
|
|
16
15
|
let file
|
|
17
16
|
if (path.isAbsolute(source)) file = source
|
|
18
17
|
else {
|
|
19
|
-
file = `${getPluginDataDir(this.ns)}/import/${source}`
|
|
18
|
+
file = `${this.app.getPluginDataDir(this.ns)}/import/${source}`
|
|
20
19
|
fs.ensureDirSync(path.dirname(file))
|
|
21
20
|
}
|
|
22
21
|
if (!fs.existsSync(file)) throw this.error('sourceFileNotExists%s', file)
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED