Skip to content

Commit

Permalink
fixing review points
Browse files Browse the repository at this point in the history
  • Loading branch information
mondus committed Nov 20, 2024
1 parent 237f098 commit 3f93cb1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/flamegpu/io/Telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,14 @@ std::string Telemetry::getUserId() {
if (std::filesystem::exists(filePath)) {
std::ifstream file(filePath);
if (file.is_open()) {
std::getline(file, userId); // overwrite existing Id
std::string cached_id;
std::getline(file, cached_id); // overwrite existing Id
file.close();
return userId; // Config file and user id found so return it
// Config file and user id found so return it if not empty (either because file is externally modified or file is a directory)
if (!cached_id.empty())
return cached_id;
else
return userId;
}
else {
throw std::runtime_error("Unable to open user ID file for reading");
Expand All @@ -382,7 +387,7 @@ std::string Telemetry::getUserId() {
throw std::runtime_error("Unable to create user ID file");
}
} catch (const std::exception&) {
fprintf(stderr, "Warning: Telemetry User Id file is not read/writeable from config file. A new User Id will be used.");
fprintf(stderr, "Warning: Telemetry User Id file is not read/writeable from config file. A new User Id will be used.\n");
}
return userId;
}
Expand Down

0 comments on commit 3f93cb1

Please sign in to comment.