Handle error condition instead of asserting, since it is occassionaly hit.

This needs to be debugged later.
This commit is contained in:
Jacob Dufault 2017-09-22 00:39:59 -07:00
parent 6b0c3831fa
commit 87394de1cf

View File

@ -4,7 +4,6 @@
#include "language_server_api.h" #include "language_server_api.h"
#include "platform.h" #include "platform.h"
#include <loguru/loguru.hpp> #include <loguru/loguru.hpp>
#include <algorithm> #include <algorithm>
@ -51,15 +50,17 @@ void WriteToCache(Config* config, IndexFile& file) {
std::string cache_basename = std::string cache_basename =
GetCachedBaseFileName(config->cacheDirectory, file.path); GetCachedBaseFileName(config->cacheDirectory, file.path);
LOG_IF_S(ERROR, file.file_contents_.empty()) if (file.file_contents_.empty()) {
<< "Writing " << file.path << " to cache but it has no contents"; LOG_S(ERROR) << "No cached file contents; performing potentially stale "
<< "file-copy for " << file.path;
assert(!file.file_contents_.empty()); CopyFileTo(cache_basename, file.path);
std::ofstream cache_content; } else {
cache_content.open(cache_basename); std::ofstream cache_content;
assert(cache_content.good()); cache_content.open(cache_basename);
cache_content << file.file_contents_; assert(cache_content.good());
cache_content.close(); cache_content << file.file_contents_;
cache_content.close();
}
std::string indexed_content = Serialize(file); std::string indexed_content = Serialize(file);
std::ofstream cache; std::ofstream cache;