Skip to content

Commit

Permalink
Merge pull request #481 from /issues/450
Browse files Browse the repository at this point in the history
Add error messaging for if a file fails to download
  • Loading branch information
drewjenkins authored Apr 29, 2021
2 parents 2ca0f44 + b4d1112 commit 353faed
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions packages/cli-lib/fileMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ async function writeFileMapperNode(input, node, filepath) {
if (!node.folder) {
try {
await fetchAndWriteFileStream(input, node.path, filepath);
return;
} catch (err) {
// Logging handled by handler
return false;
}
return;
}
try {
await fs.ensureDir(filepath);
Expand All @@ -329,6 +329,7 @@ async function writeFileMapperNode(input, node, filepath) {
write: true,
})
);
return false;
}
}

Expand Down Expand Up @@ -453,19 +454,36 @@ async function downloadFolder(input) {
dest === getCwd()
? convertToLocalFileSystemPath(path.resolve(dest, node.name))
: dest;
let success = true;
recurseFolder(
node,
(childNode, { filepath }) => {
queue.add(() => writeFileMapperNode(input, childNode, filepath));
queue.add(async () => {
const succeeded = await writeFileMapperNode(
input,
childNode,
filepath
);
if (succeeded === false) {
success = false;
}
});
},
rootPath
);
await queue.onIdle();
logger.success(
'Completed fetch of folder "%s" to "%s" from the Design Manager',
input.src,
input.dest
);

if (success) {
logger.success(
'Completed fetch of folder "%s" to "%s" from the Design Manager',
input.src,
input.dest
);
} else {
logger.error(
`Not all files in folder "${input.src}" were successfully fetched. Re-run the last command to try again`
);
}
} catch (err) {
logger.error(
'Failed fetch of folder "%s" to "%s" from the Design Manager',
Expand Down

0 comments on commit 353faed

Please sign in to comment.