|
1 | | -import { pathExists, readdir, stat, remove, readFile } from "fs-extra"; |
| 1 | +import { pathExists, stat, remove, readFile } from "fs-extra"; |
2 | 2 | import { EOL } from "os"; |
3 | 3 | import { join } from "path"; |
4 | 4 | import { Disposable, ExtensionContext } from "vscode"; |
5 | 5 | import { extLogger } from "../common"; |
| 6 | +import { readDirFullPaths } from "../pure/files"; |
6 | 7 | import { QueryHistoryDirs } from "./query-history-dirs"; |
7 | 8 | import { QueryHistoryManager } from "./query-history-manager"; |
8 | 9 |
|
@@ -75,18 +76,33 @@ async function scrubQueries( |
75 | 76 | let scrubCount = 0; // total number of directories deleted |
76 | 77 | try { |
77 | 78 | counter?.increment(); |
78 | | - void extLogger.log("Scrubbing query directory. Removing old queries."); |
| 79 | + void extLogger.log( |
| 80 | + "Cleaning up query history directories. Removing old entries.", |
| 81 | + ); |
| 82 | + |
79 | 83 | if (!(await pathExists(queryHistoryDirs.localQueriesDirPath))) { |
80 | 84 | void extLogger.log( |
81 | | - `Cannot scrub. Query directory does not exist: ${queryHistoryDirs.localQueriesDirPath}`, |
| 85 | + `Cannot clean up query history directories. Local queries directory does not exist: ${queryHistoryDirs.localQueriesDirPath}`, |
| 86 | + ); |
| 87 | + return; |
| 88 | + } |
| 89 | + if (!(await pathExists(queryHistoryDirs.variantAnalysesDirPath))) { |
| 90 | + void extLogger.log( |
| 91 | + `Cannot clean up query history directories. Variant analyses directory does not exist: ${queryHistoryDirs.variantAnalysesDirPath}`, |
82 | 92 | ); |
83 | 93 | return; |
84 | 94 | } |
85 | 95 |
|
86 | | - const baseNames = await readdir(queryHistoryDirs.localQueriesDirPath); |
| 96 | + const localQueryDirPaths = await readDirFullPaths( |
| 97 | + queryHistoryDirs.localQueriesDirPath, |
| 98 | + ); |
| 99 | + const variantAnalysisDirPaths = await readDirFullPaths( |
| 100 | + queryHistoryDirs.variantAnalysesDirPath, |
| 101 | + ); |
| 102 | + const allDirPaths = [...localQueryDirPaths, ...variantAnalysisDirPaths]; |
| 103 | + |
87 | 104 | const errors: string[] = []; |
88 | | - for (const baseName of baseNames) { |
89 | | - const dir = join(queryHistoryDirs.localQueriesDirPath, baseName); |
| 105 | + for (const dir of allDirPaths) { |
90 | 106 | const scrubResult = await scrubDirectory(dir, now, maxQueryTime); |
91 | 107 | if (scrubResult.errorMsg) { |
92 | 108 | errors.push(scrubResult.errorMsg); |
|
0 commit comments