From 98d16d27cf3e13003fd5782f928acc22971b7a84 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Thu, 12 Oct 2023 19:20:37 +0300 Subject: [PATCH] only update cache file if something changed Summary: See Q77. When installing in a read-only location, updating the file is both redundant (nothing changed) and fails. Make sure to only save the updated file if anything changed. Test Plan: Run `arc lint` somewhere, make `.phutil_module_cache` and `src/` read-only, run `arc lint` again - it should avoid crashing. Reviewers: fgaz, O1 Blessed Committers, valerio.bozzolan Reviewed By: fgaz, O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25446 --- src/moduleutils/PhutilLibraryMapBuilder.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/moduleutils/PhutilLibraryMapBuilder.php b/src/moduleutils/PhutilLibraryMapBuilder.php index f51fc464..df05050a 100644 --- a/src/moduleutils/PhutilLibraryMapBuilder.php +++ b/src/moduleutils/PhutilLibraryMapBuilder.php @@ -469,10 +469,12 @@ EOPHP; $this->fileSymbolMap = $symbol_map; - // We're done building the cache, so write it out immediately. Note that - // we've only retained entries for files we found, so this implicitly cleans - // out old cache entries. - $this->writeSymbolCache($symbol_map, $source_map); + if ($futures) { + // We're done building/updating the cache, so write it out immediately. + // Note that we've only retained entries for files we found, so this + // implicitly cleans out old cache entries. + $this->writeSymbolCache($symbol_map, $source_map); + } // Our map is up to date, so either show it on stdout or write it to disk. $this->librarySymbolMap = $this->buildLibraryMap($symbol_map);