mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 05:20:05 +00:00
Use binary streams to make DB backups, since filesystem has low compat
This commit is contained in:
parent
2e173df2ca
commit
ea12ec9607
@ -16,7 +16,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
||||||
#include "mingw/mingw.mutex.h"
|
#include "mingw/mingw.mutex.h"
|
||||||
@ -137,14 +136,13 @@ void Database::checkMetaTable() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
} else if (dbVersion < DATABASE_VERSION) {
|
} else if (dbVersion < DATABASE_VERSION) {
|
||||||
// we're gonna migrate; back up the DB
|
// we're gonna migrate; back up the DB
|
||||||
try {
|
std::cout << "[INFO] Backing up database" << std::endl;
|
||||||
std::cout << "[INFO] Backing up database" << std::endl;
|
// copy db file over using binary streams
|
||||||
std::filesystem::copy_file(settings::DBPATH, settings::DBPATH + ".old." + std::to_string(dbVersion));
|
std::ifstream src(settings::DBPATH, std::ios::binary);
|
||||||
}
|
std::ofstream dst(settings::DBPATH + ".old." + std::to_string(dbVersion), std::ios::binary);
|
||||||
catch (std::filesystem::filesystem_error& e) {
|
dst << src.rdbuf();
|
||||||
std::cout << "[FATAL] Failed to backup database before migration" << std::endl;
|
src.close();
|
||||||
exit(1);
|
dst.close();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (dbVersion != DATABASE_VERSION) {
|
while (dbVersion != DATABASE_VERSION) {
|
||||||
|
Loading…
Reference in New Issue
Block a user