From eb5c09de7657f3667c89576debf54c6aaa918fba Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Wed, 6 Dec 2023 09:25:25 -0800 Subject: [PATCH] update clear files --- backend/src/routes/download-router.js | 9 +++++++++ tests-e2e/cypress/e2e/authority.cy.ts | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/download-router.js b/backend/src/routes/download-router.js index bf6b907..9377b8a 100644 --- a/backend/src/routes/download-router.js +++ b/backend/src/routes/download-router.js @@ -24,6 +24,15 @@ async function flushFileCache(req, res) { } fileCache.flushAll(); schoolCache.flushAll(); + const directoryPath = FILE_STORAGE_DIR ; + // Read all files in the directory + fs.readdirSync(directoryPath).forEach((file) => { + const filePath = path.join(directoryPath, file); + + // Delete each file + fs.unlinkSync(filePath); + }); + res.status(200).send('All files in the directory deleted successfully.'); } catch (error) { console.error(error); diff --git a/tests-e2e/cypress/e2e/authority.cy.ts b/tests-e2e/cypress/e2e/authority.cy.ts index 5fff519..828eed9 100644 --- a/tests-e2e/cypress/e2e/authority.cy.ts +++ b/tests-e2e/cypress/e2e/authority.cy.ts @@ -2,11 +2,11 @@ describe('Testing Authority Page', () => { before(() => { // Visit the root URL before running any test case. - cy.visit('/authority/100-Abbotsford%20Christian%20School'); + cy.visit('/authority/104-Cedars%20Christian%20School'); cy.wait(5000); // 5000 milliseconds = 5 seconds }); it('Confirm the Authority is displaying', () => { - cy.contains('h1', '100 - Abbotsford Christian School'); + cy.contains('h1', '104 - Cedars Christian School'); }); }); \ No newline at end of file