Skip to content

Commit 01b43df

Browse files
author
Max Schaefer
committed
JavaScript: Make in-dist trap cache read-only.
1 parent 032ed12 commit 01b43df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,16 @@ private void extractExterns() throws IOException {
380380
ITrapCache trapCache = this.trapCache;
381381
if (trapCache instanceof DummyTrapCache) {
382382
Path trapCachePath = SEMMLE_DIST.resolve(".cache").resolve("trap-cache").resolve("javascript");
383-
if (Files.isDirectory(trapCachePath))
384-
trapCache = new DefaultTrapCache(trapCachePath.toString(), null, Main.EXTRACTOR_VERSION);
383+
if (Files.isDirectory(trapCachePath)) {
384+
trapCache = new DefaultTrapCache(trapCachePath.toString(), null, Main.EXTRACTOR_VERSION) {
385+
@Override
386+
public File lookup(String source, ExtractorConfig config, FileType type) {
387+
File f = super.lookup(source, config, type);
388+
// only return `f` if it exists; this has the effect of making the cache read-only
389+
return f.exists() ? f : null;
390+
}
391+
};
392+
}
385393
}
386394

387395
FileExtractor extractor = new FileExtractor(config, outputConfig, trapCache, extractorState);

0 commit comments

Comments
 (0)