Skip to content

Commit ab9e14c

Browse files
caolanmAshod
authored andcommitted
failure to cache is unfortunate, but not fatal
Signed-off-by: Caolán McNamara <[email protected]> Change-Id: I2da4c8e14fbe23088db84a0944c8056d9da86060
1 parent 05f6b7a commit ab9e14c

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

wsd/CacheUtil.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,35 @@ void Cache::cacheConfigFile(const std::string& configId, const std::string& uri,
6969
if (CachePath.empty())
7070
return;
7171

72-
std::unique_lock<std::mutex> lock(CacheMutex);
72+
try
73+
{
74+
std::unique_lock<std::mutex> lock(CacheMutex);
7375

74-
Poco::Path rootPath(CachePath, Uri::encode(configId));
75-
rootPath.makeDirectory();
76+
Poco::Path rootPath(CachePath, Uri::encode(configId));
77+
rootPath.makeDirectory();
7678

77-
Poco::Path cachePath(rootPath, Uri::encode(uri));
78-
cachePath.makeDirectory();
79+
Poco::Path cachePath(rootPath, Uri::encode(uri));
80+
cachePath.makeDirectory();
7981

80-
Poco::File(cachePath).createDirectories();
82+
Poco::File(cachePath).createDirectories();
8183

82-
std::string cacheFileDir = cachePath.toString();
83-
std::string cacheFile = Poco::Path(cacheFileDir, "contents").toString();
84+
std::string cacheFileDir = cachePath.toString();
85+
std::string cacheFile = Poco::Path(cacheFileDir, "contents").toString();
8486

85-
FileUtil::copyFileTo(filename, cacheFile);
87+
FileUtil::copyFileTo(filename, cacheFile);
8688

87-
std::ofstream cacheStamp(Poco::Path(cacheFileDir, "stamp").toString());
88-
cacheStamp << stamp << '\n';
89-
cacheStamp.close();
89+
std::ofstream cacheStamp(Poco::Path(cacheFileDir, "stamp").toString());
90+
cacheStamp << stamp << '\n';
91+
cacheStamp.close();
9092

91-
updateLastUsed(rootPath.toString());
93+
updateLastUsed(rootPath.toString());
9294

93-
clearOutdatedConfigs();
95+
clearOutdatedConfigs();
96+
}
97+
catch (const std::exception& exc)
98+
{
99+
LOG_ERR("Error while caching: " << filename << " of: " << exc.what());
100+
}
94101
}
95102

96103
void Cache::updateLastUsed(const std::string& path)

0 commit comments

Comments
 (0)