Fix download task object validation

This commit is contained in:
Zaid Abdulla committed 2019-10-31 16:10:47 -07:00
1 parent ab27ebfaef
commit 765f0be7bc
2 files changed
+8 -5

No files matched your search

+7 -4
View File
@@ -226,11 +226,14 @@ function sanitizeTask(task): void {
break;
case "download":
if (typeof task.fileType !== "string" || !task.fileType.length)
throw new Error("Missing 'fileType' property");
// genieacs-gui sends file ID instead of fileName and fileType
if (!task.file) {
if (typeof task.fileType !== "string" || !task.fileType.length)
throw new Error("Missing 'fileType' property");
if (typeof task.fileName !== "string" || !task.fileName.length)
throw new Error("Missing 'fileName' property");
if (typeof task.fileName !== "string" || !task.fileName.length)
throw new Error("Missing 'fileName' property");
}
if (
task.targetFileName != null &&
+1 -1
View File
@@ -670,7 +670,7 @@ async function nextRpc(sessionContext: SessionContext): Promise<void> {
break;
case "download":
session.addProvisions(sessionContext, `task_${task._id}`, [
["download", task.fileType, task.fileName, task.targetFileName]
["download", task.fileType, task.fileName, task.targetFileName || ""]
]);
break;
case "addObject":