Skip to content

Commit

Permalink
Adjust clean jobs for CDDL extracts (#1414)
Browse files Browse the repository at this point in the history
The clean jobs did not expect multiple extracts per property and would happily
have dropped CDDL extracts.
  • Loading branch information
tidoust authored Dec 17, 2024
1 parent f91335b commit ac1425f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tools/clean-abandoned-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function checkDir(path, index) {
const dir = fs.readdirSync(path);
for (let filename of dir) {
const subdir = path.split("/")[1];
if (!index.results.find(spec => spec[subdir] === subdir + "/" + filename)) {
const fullname = subdir + "/" + filename
if (!index.results.find(spec =>
spec[subdir] === fullname ||
spec[subdir]?.find(extract => extract.file === fullname))) {
fs.unlinkSync(path + "/" + filename);
}
}
Expand Down
6 changes: 5 additions & 1 deletion tools/clean-dropped-specs-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ async function cleanExtractFolder(folder, crawlResults) {
for (const filename of dir) {
const specname = path.basename(filename, path.extname(filename));
const spec = crawlResults
.find(s => s.shortname === specname || s.series?.shortname === specname);
.find(s => s.shortname === specname ||
s.series?.shortname === specname ||
// CDDL extracts may end with CDDL module name
s.shortname.startsWith(specname + '-')
);
if (!spec) {
const fileToDrop = path.join(folder, filename);
await fs.unlink(fileToDrop);
Expand Down

0 comments on commit ac1425f

Please sign in to comment.