@datatruck/cli 0.34.3 → 0.34.5
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/actions/BackupAction.js +125 -39
- package/lib/actions/ConfigAction.js +1 -1
- package/lib/actions/CopyAction.js +110 -74
- package/lib/actions/InitAction.js +1 -1
- package/lib/actions/PruneAction.js +3 -2
- package/lib/actions/RestoreAction.d.ts +0 -2
- package/lib/actions/RestoreAction.js +131 -62
- package/lib/cli.js +1 -1
- package/lib/commands/StartServerCommand.js +2 -1
- package/lib/repositories/DatatruckRepository.d.ts +1 -1
- package/lib/repositories/DatatruckRepository.js +31 -18
- package/lib/repositories/GitRepository.js +11 -3
- package/lib/repositories/RepositoryAbstract.d.ts +2 -1
- package/lib/repositories/RepositoryAbstract.js +3 -1
- package/lib/repositories/ResticRepository.js +1 -1
- package/lib/tasks/GitTask.js +2 -1
- package/lib/tasks/MssqlTask.js +2 -2
- package/lib/tasks/MysqlDumpTask.js +1 -1
- package/lib/tasks/SqlDumpTaskAbstract.js +2 -2
- package/lib/utils/async-process.js +3 -2
- package/lib/utils/cli.js +10 -10
- package/lib/utils/data-format.js +3 -3
- package/lib/utils/datatruck/client.d.ts +7 -3
- package/lib/utils/datatruck/client.js +9 -2
- package/lib/utils/datatruck/command.js +1 -1
- package/lib/utils/datatruck/config.js +4 -4
- package/lib/utils/datatruck/report-list.js +2 -1
- package/lib/utils/datatruck/repository.d.ts +3 -3
- package/lib/utils/datatruck/repository.js +4 -4
- package/lib/utils/datatruck/task.js +1 -1
- package/lib/utils/{datatruck/error.d.ts → error.d.ts} +1 -1
- package/lib/utils/{datatruck/error.js → error.js} +2 -2
- package/lib/utils/fs.d.ts +2 -1
- package/lib/utils/fs.js +22 -3
- package/lib/utils/git.d.ts +5 -0
- package/lib/utils/git.js +10 -0
- package/lib/utils/list.d.ts +3 -1
- package/lib/utils/list.js +2 -3
- package/lib/utils/mysql.js +1 -1
- package/lib/utils/object.d.ts +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/progress.d.ts +8 -1
- package/lib/utils/progress.js +38 -5
- package/lib/utils/reportSteps.js +3 -2
- package/lib/utils/string.js +1 -1
- package/lib/utils/temp.d.ts +13 -10
- package/lib/utils/temp.js +47 -40
- package/package.json +1 -1
package/lib/utils/temp.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GargabeCollector = exports.
|
|
6
|
+
exports.GargabeCollector = exports.useTempFile = exports.useTempDir = exports.mkTmpDir = exports.collectors = exports.tmpDir = exports.rmTmpDir = exports.isTmpDir = exports.ensureFreeDiskTempSpace = exports.sessionTmpDir = exports.parentTmpDir = void 0;
|
|
7
7
|
const globalData_1 = __importDefault(require("../globalData"));
|
|
8
8
|
const fs_1 = require("./fs");
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
@@ -44,12 +44,15 @@ exports.rmTmpDir = rmTmpDir;
|
|
|
44
44
|
function tmpDir(...keys) {
|
|
45
45
|
const id = (0, crypto_1.randomUUID)().slice(0, 8);
|
|
46
46
|
const path = (0, path_1.join)(sessionTmpDir(), [...keys, id].map(encodeURIComponent).join("-"));
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if (exports.collectors.size) {
|
|
48
|
+
const lastListener = [...exports.collectors.values()].at(exports.collectors.size - 1);
|
|
49
|
+
if (lastListener)
|
|
50
|
+
lastListener.paths.add(path);
|
|
51
|
+
}
|
|
49
52
|
return path;
|
|
50
53
|
}
|
|
51
54
|
exports.tmpDir = tmpDir;
|
|
52
|
-
|
|
55
|
+
exports.collectors = new Set();
|
|
53
56
|
async function mkTmpDir(...keys) {
|
|
54
57
|
const path = tmpDir(...keys);
|
|
55
58
|
await (0, promises_1.mkdir)(path, { recursive: true });
|
|
@@ -81,53 +84,57 @@ function useTempFile(path) {
|
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
exports.useTempFile = useTempFile;
|
|
84
|
-
class CleanupListener {
|
|
85
|
-
paths = [];
|
|
86
|
-
stop() {
|
|
87
|
-
listeners.delete(this);
|
|
88
|
-
}
|
|
89
|
-
async dispose() {
|
|
90
|
-
this.stop();
|
|
91
|
-
await rmTmpDir(this.paths);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.CleanupListener = CleanupListener;
|
|
95
87
|
class GargabeCollector {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
parent;
|
|
89
|
+
paths = new Set();
|
|
90
|
+
children = new Set();
|
|
91
|
+
constructor(parent) {
|
|
92
|
+
this.parent = parent;
|
|
93
|
+
exports.collectors.add(this);
|
|
99
94
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
pending() {
|
|
96
|
+
if (this.paths.size)
|
|
97
|
+
return true;
|
|
98
|
+
for (const child of this.children)
|
|
99
|
+
if (child.pending())
|
|
100
|
+
return true;
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
async cleanup() {
|
|
104
|
+
for (const path of this.paths) {
|
|
105
|
+
try {
|
|
106
|
+
await rmTmpDir(path);
|
|
107
|
+
this.paths.delete(path);
|
|
108
108
|
}
|
|
109
|
+
catch (_) { }
|
|
109
110
|
}
|
|
111
|
+
for (const child of this.children)
|
|
112
|
+
await child.cleanup();
|
|
110
113
|
}
|
|
111
|
-
async
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
await cb();
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
cleanup.dispose();
|
|
118
|
-
}
|
|
114
|
+
async dispose() {
|
|
115
|
+
await this.cleanup();
|
|
116
|
+
exports.collectors.delete(this);
|
|
119
117
|
}
|
|
120
|
-
async
|
|
121
|
-
const cleanup = new CleanupListener();
|
|
118
|
+
async disposeIfFail(cb) {
|
|
122
119
|
try {
|
|
123
|
-
await cb();
|
|
120
|
+
return await cb();
|
|
124
121
|
}
|
|
125
122
|
catch (error) {
|
|
126
|
-
await
|
|
123
|
+
await this.dispose();
|
|
127
124
|
throw error;
|
|
128
125
|
}
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
}
|
|
127
|
+
disposeOnFinish() {
|
|
128
|
+
return {
|
|
129
|
+
[Symbol.asyncDispose]: async () => {
|
|
130
|
+
return this.dispose();
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
create() {
|
|
135
|
+
const gc = new GargabeCollector();
|
|
136
|
+
this.children.add(gc);
|
|
137
|
+
return gc;
|
|
131
138
|
}
|
|
132
139
|
}
|
|
133
140
|
exports.GargabeCollector = GargabeCollector;
|