Skip to content

Commit

Permalink
campaignd: Rename a server class field and some scoped_ostream objects
Browse files Browse the repository at this point in the history
The file_ field is now cfg_file_ to avoid ambiguity ("what file and for
what?"). Since there are a lot of scoped_ostream instantiations around
named cfgfile which are used to write to the cfg_file_ path, those are
now renamed to simply out, also to avoid ambiguity -- just an
intermediate step before refactoring those into a separate method.
  • Loading branch information
irydacea committed Jun 11, 2014
1 parent 23ce3f8 commit 796b77d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/campaign_server/campaign_server.cpp
Expand Up @@ -173,7 +173,7 @@ namespace campaignd {

server::server(const std::string& cfg_file, size_t min_threads, size_t max_threads)
: cfg_()
, file_(cfg_file)
, cfg_file_(cfg_file)
, read_only_(false)
, compress_level_(0)
, input_(0)
Expand All @@ -196,13 +196,13 @@ server::server(const std::string& cfg_file, size_t min_threads, size_t max_threa
server::~server()
{
delete input_;
scoped_ostream out = ostream_file(file_);
scoped_ostream out = ostream_file(cfg_file_);
write(*out, cfg_);
}

int server::load_config()
{
scoped_istream in = istream_file(file_);
scoped_istream in = istream_file(cfg_file_);
read(cfg_, *in);

read_only_ = cfg_["read_only"].to_bool(false);
Expand Down Expand Up @@ -251,12 +251,12 @@ void server::load_blacklist()
}

try {
scoped_istream stream = istream_file(blacklist_file_);
config cfg;
scoped_istream in = istream_file(blacklist_file_);
config blcfg;

read(cfg, *stream);
read(blcfg, *in);

blacklist_.read(cfg);
blacklist_.read(blcfg);
LOG_CS << "using blacklist from " << blacklist_file_ << '\n';
} catch(const config::error&) {
LOG_CS << "ERROR: failed to read blacklist from " << blacklist_file_ << ", blacklist disabled\n";
Expand Down Expand Up @@ -371,8 +371,8 @@ void server::run()
}
//write config to disk every ten minutes
if((increment%(60*10*50)) == 0) {
scoped_ostream cfgfile = ostream_file(file_);
write(*cfgfile, cfg_);
scoped_ostream out = ostream_file(cfg_file_);
write(*out, cfg_);
}

network::process_send_queue();
Expand Down Expand Up @@ -630,8 +630,8 @@ void server::run()

(*campaign)["size"] = lexical_cast<std::string>(
file_size(filename));
scoped_ostream cfgfile = ostream_file(file_);
write(*cfgfile, cfg_);
scoped_ostream out = ostream_file(cfg_file_);
write(*out, cfg_);
network::send_data(construct_message(message), sock);

fire("hook_post_upload", upload["name"]);
Expand Down Expand Up @@ -673,8 +673,8 @@ void server::run()
break;
}
}
scoped_ostream cfgfile = ostream_file(file_);
write(*cfgfile, cfg_);
scoped_ostream out = ostream_file(cfg_file_);
write(*out, cfg_);
network::send_data(construct_message("Add-on deleted."), sock);

fire("hook_post_erase", erase["name"]);
Expand All @@ -696,8 +696,8 @@ void server::run()
network::send_data(construct_error("No new passphrase was supplied."), sock);
} else {
campaign["passphrase"] = cpass["new_passphrase"];
scoped_ostream cfgfile = ostream_file(file_);
write(*cfgfile, cfg_);
scoped_ostream out = ostream_file(cfg_file_);
write(*out, cfg_);
network::send_data(construct_message("Passphrase changed."), sock);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/campaign_server/campaign_server.hpp
Expand Up @@ -39,7 +39,7 @@ class server : private boost::noncopyable

private:
config cfg_;
const std::string file_;
const std::string cfg_file_;

bool read_only_;
int compress_level_; /**< Used for add-on archives. */
Expand Down

0 comments on commit 796b77d

Please sign in to comment.