From 5d91e9693fc70f6276e6a87738b38afd7c482ee2 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Fri, 12 Aug 2022 15:23:20 +0800 Subject: [PATCH] [Error] Do not show warning when the offline cache path does not exist (#5747) * [Error] Do not show warning when the offline cache path does not exist * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- taichi/runtime/llvm/llvm_offline_cache.cpp | 3 +++ taichi/util/io.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/taichi/runtime/llvm/llvm_offline_cache.cpp b/taichi/runtime/llvm/llvm_offline_cache.cpp index c0fa66ca07f89..523d38382afa5 100644 --- a/taichi/runtime/llvm/llvm_offline_cache.cpp +++ b/taichi/runtime/llvm/llvm_offline_cache.cpp @@ -376,6 +376,9 @@ void LlvmOfflineCacheFileWriter::clean_cache(const std::string &path, { std::string lock_path = taichi::join_path(path, kMetadataFileLockName); if (!lock_with_file(lock_path)) { + if (!taichi::path_exists(path)) { + return; + } TI_WARN("Lock {} failed", lock_path); return; } diff --git a/taichi/util/io.h b/taichi/util/io.h index 4a47f7310012e..30c41f9151692 100644 --- a/taichi/util/io.h +++ b/taichi/util/io.h @@ -10,6 +10,7 @@ #include #include #include +#include #if defined(TI_PLATFORM_WINDOWS) #include @@ -17,6 +18,11 @@ TI_NAMESPACE_BEGIN +inline bool path_exists(const std::string &dir) { + struct stat buffer; + return stat(dir.c_str(), &buffer) == 0; +} + // TODO: move to std::filesystem after it's nonexperimental on all platforms inline void create_directories(const std::string &dir) { #if defined(TI_PLATFORM_WINDOWS)