cacth error when reading archive

This commit is contained in:
Jan Prochazka 2022-06-12 09:16:10 +02:00
parent 13b549ca2c
commit 44827ea504

View File

@ -1,11 +1,8 @@
const fs = require('fs-extra'); const fs = require('fs-extra');
const stream = require('stream');
const readline = require('readline'); const readline = require('readline');
const path = require('path'); const path = require('path');
const { formatWithOptions } = require('util');
const { archivedir, clearArchiveLinksCache, resolveArchiveFolder } = require('../utility/directories'); const { archivedir, clearArchiveLinksCache, resolveArchiveFolder } = require('../utility/directories');
const socket = require('../utility/socket'); const socket = require('../utility/socket');
const JsonLinesDatastore = require('../utility/JsonLinesDatastore');
const { saveFreeTableData } = require('../utility/freeTableStorage'); const { saveFreeTableData } = require('../utility/freeTableStorage');
const loadFilesRecursive = require('../utility/loadFilesRecursive'); const loadFilesRecursive = require('../utility/loadFilesRecursive');
@ -45,6 +42,7 @@ module.exports = {
files_meta: true, files_meta: true,
async files({ folder }) { async files({ folder }) {
try {
const dir = resolveArchiveFolder(folder); const dir = resolveArchiveFolder(folder);
if (!(await fs.exists(dir))) return []; if (!(await fs.exists(dir))) return [];
const files = await loadFilesRecursive(dir); // fs.readdir(dir); const files = await loadFilesRecursive(dir); // fs.readdir(dir);
@ -68,6 +66,10 @@ module.exports = {
...fileType('.trigger.sql', 'trigger.sql'), ...fileType('.trigger.sql', 'trigger.sql'),
...fileType('.matview.sql', 'matview.sql'), ...fileType('.matview.sql', 'matview.sql'),
]; ];
} catch (err) {
console.log('Error reading archive files', err.message);
return [];
}
}, },
refreshFiles_meta: true, refreshFiles_meta: true,