Core/Updater: Use a different method for file reading
* Current method causes issues under CentOS 6 and could possibly lead to cutted buffer content when reading in textmode. * Closes #16209
This commit is contained in:
1 parent
4cd937140b
commit
ae1a5c6c2b
2 files changed
+6
-8
No files matched your search
@@ -142,14 +142,12 @@ UpdateFetcher::SQLUpdate UpdateFetcher::ReadSQLUpdate(boost::filesystem::path co
|
|||||||
std::ifstream in(file.c_str());
|
std::ifstream in(file.c_str());
|
||||||
WPFatal(in.is_open(), "Could not read an update file.");
|
WPFatal(in.is_open(), "Could not read an update file.");
|
||||||
|
|
||||||
auto const start_pos = in.tellg();
|
auto update = [&in] {
|
||||||
in.ignore(std::numeric_limits<std::streamsize>::max());
|
std::ostringstream ss;
|
||||||
auto const char_count = in.gcount();
|
ss << in.rdbuf();
|
||||||
in.seekg(start_pos);
|
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();
|
in.close();
|
||||||
return update;
|
return update;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ private:
|
|||||||
typedef std::unordered_map<std::string, std::string> HashToFileNameStorage;
|
typedef std::unordered_map<std::string, std::string> HashToFileNameStorage;
|
||||||
typedef std::unordered_map<std::string, AppliedFileEntry> AppliedFileStorage;
|
typedef std::unordered_map<std::string, AppliedFileEntry> AppliedFileStorage;
|
||||||
typedef std::vector<UpdateFetcher::DirectoryEntry> DirectoryStorage;
|
typedef std::vector<UpdateFetcher::DirectoryEntry> DirectoryStorage;
|
||||||
typedef std::shared_ptr<std::string> SQLUpdate;
|
typedef std::unique_ptr<std::string> SQLUpdate;
|
||||||
|
|
||||||
LocaleFileStorage GetFileList() const;
|
LocaleFileStorage GetFileList() const;
|
||||||
void FillFileListRecursively(Path const& path, LocaleFileStorage& storage, State const state, uint32 const depth) const;
|
void FillFileListRecursively(Path const& path, LocaleFileStorage& storage, State const state, uint32 const depth) const;
|
||||||
|
|||||||
Reference in new issue
Block a user