From b2b347fc7269a1a0c6622ee955f8bfd3386ae1f5 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 20 Jan 2022 17:31:56 -0500 Subject: [PATCH] fix(striker-ui-api): complete file upload endpoint --- striker-ui-api/lib/accessDB.js | 8 ++++++-- striker-ui-api/routes/files.js | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/striker-ui-api/lib/accessDB.js b/striker-ui-api/lib/accessDB.js index 47727236..5706f24c 100644 --- a/striker-ui-api/lib/accessDB.js +++ b/striker-ui-api/lib/accessDB.js @@ -60,12 +60,11 @@ const accessDB = { jobData, jobTitle, jobDescription, - { jobHostUUID } = { jobHostUUID: 'all' }, + { jobHostUUID } = { jobHostUUID: undefined }, ) => { const subParams = { file: __filename, line: 0, - job_host_uuid: jobHostUUID, job_command: SERVER_PATHS.usr.sbin['anvil-sync-shared'].self, job_data: jobData, job_name: `storage::${jobName}`, @@ -73,6 +72,11 @@ const accessDB = { job_description: `job_${jobDescription}`, job_progress: 0, }; + + if (jobHostUUID) { + subParams.job_host_uuid = jobHostUUID; + } + console.log(JSON.stringify(subParams, null, 2)); return execDatabaseModuleSubroutine('insert_or_update_jobs', subParams) diff --git a/striker-ui-api/routes/files.js b/striker-ui-api/routes/files.js index cf40766f..176e2325 100644 --- a/striker-ui-api/routes/files.js +++ b/striker-ui-api/routes/files.js @@ -30,7 +30,9 @@ router WHERE file_uuid = '${fileUUID}';`, ).stdout; - dbJobAnvilSyncShared('purge', `file_uuid=${fileUUID}`, '0136', '0137'); + dbJobAnvilSyncShared('purge', `file_uuid=${fileUUID}`, '0136', '0137', { + jobHostUUID: 'all', + }); } response.status(204).send(); @@ -41,17 +43,22 @@ router console.log('Receiving shared file.'); if (file) { - console.log(`file:`); - console.dir(file); - - console.log('body:'); - console.dir(body); + console.log(`file: ${JSON.stringify(file, null, 2)}`); + console.log(`body: ${JSON.stringify(body, null, 2)}`); + + dbJobAnvilSyncShared( + 'move_incoming', + `file=${file.path}`, + '0132', + '0133', + ); response.status(200).send(); } }) .put('/:fileUUID', (request, response) => { console.log('Begin edit single file.'); + console.dir(request.body); const { fileUUID } = request.params; const { fileName, fileLocations, fileType } = request.body; @@ -79,6 +86,7 @@ router `file_uuid=${fileUUID}\nold_name=${oldFileName}\nnew_name=${fileName}`, '0138', '0139', + { jobHostUUID: 'all' }, ), ); } @@ -98,6 +106,7 @@ router `file_uuid=${fileUUID}`, '0143', '0144', + { jobHostUUID: 'all' }, ), ); }