Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check springsettings reading func #1473

Open
sprunk opened this issue Apr 27, 2024 · 0 comments
Open

Check springsettings reading func #1473

sprunk opened this issue Apr 27, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@sprunk
Copy link
Collaborator

sprunk commented Apr 27, 2024

if ((file = fopen(filename.c_str(), "r"))) {
ScopedFileLock scoped_lock(fileno(file), false);
Read(file);
fclose(file);
}
else if ((file = fopen(filename.c_str(), "a"))) {
// TODO: write some initial contents into the config file?
fclose(file);
}
else {
LOG_L(L_ERROR, "FileConfigSource: Error: Could not write to config file \"%s\"", filename.c_str());
}

AFAICT this is supposed to just open the file (specifically springsettings.cfg) for reading. I think that:

  • if the file doesn't exist, then "r" will fail and it is fine, and creating it via "a" is fine. It could produce a notice-level log.
  • if the file exists but fails to be read there should be an error message (ideally with reason like "permissions"). Retrying via "a" is probably fine but idk if there is ever a case where that would help.
  • if both methods fail the existing error log should say "could not read" and not "write".
@sprunk sprunk added the good first issue Good for newcomers label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant