@kne/fastify-file-manager 3.0.1-alpha.3 → 3.0.1

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.
@@ -381,15 +381,22 @@ module.exports = fp(async (fastify, fastifyOptions) => {
381
381
  await fs.mkdir(tmpPath);
382
382
  const files = [];
383
383
  for (const file of fileList) {
384
- const filepath = path.resolve(tmpPath, file.filename);
385
- const writeStream = fs.createWriteStream(filepath);
386
- const fileStream = await getFileReadStream(file);
387
- fileStream.pipe(writeStream);
388
- await new Promise((resolve, reject) => {
389
- writeStream.on('finish', resolve);
390
- writeStream.on('error', reject);
391
- });
392
- files.push(filepath);
384
+ try {
385
+ const fileStream = await getFileReadStream(file);
386
+ const filepath = path.resolve(tmpPath, file.filename);
387
+ const writeStream = fs.createWriteStream(filepath);
388
+ fileStream.pipe(writeStream);
389
+ await new Promise((resolve, reject) => {
390
+ writeStream.on('finish', resolve);
391
+ writeStream.on('error', reject);
392
+ });
393
+ files.push(filepath);
394
+ } catch (error) {
395
+ console.warn(`skip invalid file: ${file.uuid}`, error.message);
396
+ }
397
+ }
398
+ if (files.length === 0) {
399
+ throw new Error('No valid files to compress');
393
400
  }
394
401
  const compressStream = new compressing[type].Stream();
395
402
  files.forEach(filepath => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-file-manager",
3
- "version": "3.0.1-alpha.3",
3
+ "version": "3.0.1",
4
4
  "description": "用于管理静态文件上传查看等",
5
5
  "main": "index.js",
6
6
  "scripts": {