From 44e0428496101a7de8029e284879cbe53d0163cd Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 20 Nov 2024 16:45:36 +0100 Subject: [PATCH] Merge pull request #22019 from overleaf/jpa-cleanup [history-v1] back_fill_file_hash: cleanup BUFFER_DIR when done GitOrigin-RevId: 6413292bbe8cca470919b740d7e2b45fc5e7d824 --- .../history-v1/storage/scripts/back_fill_file_hash.mjs | 7 +++++++ .../acceptance/js/storage/back_fill_file_hash.test.mjs | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/services/history-v1/storage/scripts/back_fill_file_hash.mjs b/services/history-v1/storage/scripts/back_fill_file_hash.mjs index 15c9e8508e..742e857ac4 100644 --- a/services/history-v1/storage/scripts/back_fill_file_hash.mjs +++ b/services/history-v1/storage/scripts/back_fill_file_hash.mjs @@ -1101,6 +1101,13 @@ try { await main() } finally { printStats() + try { + // Perform non-recursive removal of the BUFFER_DIR. Individual files + // should get removed in parallel as part of batch processing. + await fs.promises.rmdir(BUFFER_DIR) + } catch (err) { + console.error(`cleanup of BUFFER_DIR=${BUFFER_DIR} failed`, err) + } } let code = 0 diff --git a/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs b/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs index 6a2a4046f7..af75d3a871 100644 --- a/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs +++ b/services/history-v1/test/acceptance/js/storage/back_fill_file_hash.test.mjs @@ -1,3 +1,4 @@ +import fs from 'node:fs' import Crypto from 'node:crypto' import Stream from 'node:stream' import { setTimeout } from 'node:timers/promises' @@ -511,6 +512,9 @@ describe('back_fill_file_hash script', function () { } result = { stdout, stderr, status: code } } + expect((await fs.promises.readdir('/tmp')).join(';')).to.not.match( + /back_fill_file_hash/ + ) const extraStatsKeys = [ 'eventLoop', 'readFromGCSThroughputMiBPerSecond',