From a7df8a6c761fca336c030d1888c2e932b0dae83f Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 11 Sep 2020 13:06:23 -0700 Subject: [PATCH] Check for a valid SkSL cache directory before calling VisitFiles The directory may be invalid when running shell_unittests because some tests call SetCacheDirectoryPath and then delete the directory. Later tests that try to use that cache base path will be unable to open the directory. --- shell/common/persistent_cache.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/common/persistent_cache.cc b/shell/common/persistent_cache.cc index 3b1d33d137542..abaafffaed43d 100644 --- a/shell/common/persistent_cache.cc +++ b/shell/common/persistent_cache.cc @@ -194,7 +194,9 @@ std::vector PersistentCache::LoadSkSLs() { // opened directory (https://github.com/flutter/flutter/issues/65258). fml::UniqueFD fresh_dir = fml::OpenDirectoryReadOnly(*cache_directory_, kSkSLSubdirName); - fml::VisitFiles(fresh_dir, visitor); + if (fresh_dir.is_valid()) { + fml::VisitFiles(fresh_dir, visitor); + } } std::unique_ptr mapping = nullptr;