Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
url: `${process.env.DOMAIN}/`
};
for (const chunk of req.body.files) {
const { uuid, count } = chunk;
// console.log('Chunk', chunk);
const chunkOutput = path.join(__dirname,
'..',
'..',
'..',
'..',
process.env.UPLOAD_FOLDER,
'chunks',
uuid);
const chunkDir = await jetpack.list(chunkOutput);
const ext = path.extname(chunkDir[0]);
const output = path.join(__dirname,
'..',
'..',
'..',
'..',
process.env.UPLOAD_FOLDER,
`${filename}${ext || ''}`);
chunkDir.sort();
// Save some data
info.name = `${filename}${ext || ''}`;
info.url += `${filename}${ext || ''}`;
for (let i = 0; i < chunkDir.length; i++) {
const dir = path.join(__dirname,
function copyDirSync(path, dest) {
let flist = jetpack.list(path)
for (let i = 0; i < flist.length; i++) {
let absolutePath = `${path}/${flist[i]}`
if (jetpack.exists(absolutePath) == "file") { // 是文件则复制
jetpack.copy(absolutePath, `${dest}/${flist[i]}`, {
overwrite: true
});
}
if (jetpack.exists(absolutePath) == "dir") { // 是目录则递归
copyDirSync(absolutePath, `${dest}/${flist[i]}`)
}
}
}
fh.deleteEmptyFolders = function(folder) {
let canDelete = true;
jetpack.list(folder).forEach(filename => {
let filePath = fh.path(folder, filename),
isDir = jetpack.exists(filePath) === 'dir';
canDelete = isDir && fh.deleteEmptyFolders(filePath) && canDelete;
});
if (canDelete) jetpack.remove(folder);
return canDelete;
};
function selectResources(dir, resources) {
if (!fs.exists(dir)) {
fs.dir(dir);
}
fs.list(dir)
.filter(file => file !== '.keep')
.forEach(file => fs.remove(`${dir}/${file}`));
if (resources && resources.length) {
resources.forEach((file) => {
const src = path.resolve(`${dir}-available/${file}`);
const dest = path.resolve(`${dir}/${file}`);
if (fs.exists(src)) {
fs.symlink(src, dest);
log.info(`Selected ${dir}: ${dir}/${file}`);
} else {