node-automator 1.3.6 → 1.3.8
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/commands/ali_oss.js +27 -3
- package/package.json +1 -1
package/commands/ali_oss.js
CHANGED
|
@@ -89,8 +89,33 @@ class AliOssCommand extends BaseCommand {
|
|
|
89
89
|
let cacheParam = this.selfData.cache_param;
|
|
90
90
|
let cachedFiles = null;
|
|
91
91
|
getCache(cacheKey, cacheType, cacheParam).then((_cachedFiles) => {
|
|
92
|
-
cachedFiles = _cachedFiles
|
|
92
|
+
cachedFiles = _cachedFiles;
|
|
93
93
|
info(`cacheKey=${cacheKey}, cacheType=${cacheType}, cacheParam=${cacheParam},cachedFiles=${JSON.stringify(cachedFiles).substring(0, 20)}`);
|
|
94
|
+
if (!cachedFiles || !Object.keys(cachedFiles).length) {
|
|
95
|
+
let marker = null;
|
|
96
|
+
var objs = [];
|
|
97
|
+
async function list () {
|
|
98
|
+
do {
|
|
99
|
+
const result = await client.list({
|
|
100
|
+
prefix: dst_folder + "/",
|
|
101
|
+
marker: marker,
|
|
102
|
+
});
|
|
103
|
+
marker = result.nextMarker;
|
|
104
|
+
objs.push.apply(objs, result.objects);
|
|
105
|
+
} while (marker);
|
|
106
|
+
return objs;
|
|
107
|
+
}
|
|
108
|
+
list().then(objs => {
|
|
109
|
+
cachedFiles = {};
|
|
110
|
+
objs.forEach(obj => {
|
|
111
|
+
cachedFiles[obj.name] = obj.etag.replaceAll("\"", "").toLowerCase();
|
|
112
|
+
});
|
|
113
|
+
setCache(cacheKey, cachedFiles, cacheType, cacheParam);
|
|
114
|
+
uploadFiles(srcs);
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
uploadFiles(srcs);
|
|
118
|
+
}
|
|
94
119
|
function uploadFiles(srcs) {
|
|
95
120
|
let rawLength = srcs.length;
|
|
96
121
|
// 过滤文件
|
|
@@ -132,7 +157,7 @@ class AliOssCommand extends BaseCommand {
|
|
|
132
157
|
});
|
|
133
158
|
queueAsync(tasks, concurrency, (done, total, index, indexDone) => {
|
|
134
159
|
const src = srcs[index];
|
|
135
|
-
if (
|
|
160
|
+
if (indexDone) {
|
|
136
161
|
// 当前上传的,存储为 hash
|
|
137
162
|
let dst = path.join(dst_folder, path.relative(base, src)).replace(/\\/g, "/")
|
|
138
163
|
cachedFiles[dst] = crypto.createHash("md5").update(readFileSync(src)).digest("hex");
|
|
@@ -163,7 +188,6 @@ class AliOssCommand extends BaseCommand {
|
|
|
163
188
|
}
|
|
164
189
|
});
|
|
165
190
|
}
|
|
166
|
-
uploadFiles(srcs);
|
|
167
191
|
})
|
|
168
192
|
break;
|
|
169
193
|
}
|