From c3a37bec80128dac601e753096bb7444892982b8 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 11 Sep 2020 16:23:25 -0700 Subject: [PATCH] Check for a valid SkSL cache directory before calling VisitFiles (flutter/engine#21118) 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. --- engine/src/flutter/shell/common/persistent_cache.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/common/persistent_cache.cc b/engine/src/flutter/shell/common/persistent_cache.cc index 3b1d33d137..abaafffaed 100644 --- a/engine/src/flutter/shell/common/persistent_cache.cc +++ b/engine/src/flutter/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;