Skip to content

Commit

Permalink
Core/Updater: Use a different method for file reading
Browse files Browse the repository at this point in the history
* Current method causes issues under CentOS 6 and could possibly
  lead to cutted buffer content when reading in textmode.
* Closes #16209
  • Loading branch information
Naios committed Feb 20, 2016
1 parent 4cd9371 commit ae1a5c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/server/database/Updater/UpdateFetcher.cpp
Expand Up @@ -142,14 +142,12 @@ UpdateFetcher::SQLUpdate UpdateFetcher::ReadSQLUpdate(boost::filesystem::path co
std::ifstream in(file.c_str());
WPFatal(in.is_open(), "Could not read an update file.");

auto const start_pos = in.tellg();
in.ignore(std::numeric_limits<std::streamsize>::max());
auto const char_count = in.gcount();
in.seekg(start_pos);
auto update = [&in] {
std::ostringstream ss;
ss << in.rdbuf();
return Trinity::make_unique<std::string>(ss.str());
}();

SQLUpdate const update(new std::string(char_count, char{}));

in.read(&(*update)[0], update->size());
in.close();
return update;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/database/Updater/UpdateFetcher.h
Expand Up @@ -103,7 +103,7 @@ class UpdateFetcher
typedef std::unordered_map<std::string, std::string> HashToFileNameStorage;
typedef std::unordered_map<std::string, AppliedFileEntry> AppliedFileStorage;
typedef std::vector<UpdateFetcher::DirectoryEntry> DirectoryStorage;
typedef std::shared_ptr<std::string> SQLUpdate;
typedef std::unique_ptr<std::string> SQLUpdate;

LocaleFileStorage GetFileList() const;
void FillFileListRecursively(Path const& path, LocaleFileStorage& storage, State const state, uint32 const depth) const;
Expand Down

0 comments on commit ae1a5c6

Please sign in to comment.