Better logging when local state can't be loaded
This commit is contained in:
parent
0ee707397d
commit
7d40937b9a
@ -1,5 +1,7 @@
|
|||||||
Version 0.10.2 (unreleased)
|
Version 0.10.2 (unreleased)
|
||||||
---------------
|
---------------
|
||||||
|
Improvements:
|
||||||
|
* Better logging when local state can't be loaded
|
||||||
|
|
||||||
|
|
||||||
Version 0.10.1
|
Version 0.10.1
|
||||||
|
@ -40,6 +40,7 @@ CryConfig::CryConfig()
|
|||||||
CryConfig CryConfig::load(const Data &data) {
|
CryConfig CryConfig::load(const Data &data) {
|
||||||
stringstream stream;
|
stringstream stream;
|
||||||
data.StoreToStream(stream);
|
data.StoreToStream(stream);
|
||||||
|
|
||||||
ptree pt;
|
ptree pt;
|
||||||
read_json(stream, pt);
|
read_json(stream, pt);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <vendor_cryptopp/sha.h>
|
#include <vendor_cryptopp/sha.h>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include "LocalStateDir.h"
|
#include "LocalStateDir.h"
|
||||||
|
#include <cpp-utils/logging/logging.h>
|
||||||
|
|
||||||
namespace bf = boost::filesystem;
|
namespace bf = boost::filesystem;
|
||||||
using boost::property_tree::ptree;
|
using boost::property_tree::ptree;
|
||||||
@ -15,20 +16,27 @@ using std::istream;
|
|||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
using namespace cpputils::logging;
|
||||||
|
|
||||||
namespace cryfs {
|
namespace cryfs {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
ptree _load(const bf::path &metadataFilePath) {
|
ptree _load(const bf::path &metadataFilePath) {
|
||||||
ptree result;
|
try {
|
||||||
|
ptree result;
|
||||||
|
|
||||||
ifstream file(metadataFilePath.string());
|
ifstream file(metadataFilePath.string());
|
||||||
if (file.good()) {
|
if (file.good()) {
|
||||||
read_json(file, result);
|
read_json(file, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
LOG(ERR, "Error loading BasedirMetadata");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _save(const bf::path &metadataFilePath, const ptree& data) {
|
void _save(const bf::path &metadataFilePath, const ptree& data) {
|
||||||
|
@ -21,6 +21,7 @@ using cpputils::hash::Hash;
|
|||||||
using cpputils::Data;
|
using cpputils::Data;
|
||||||
using cpputils::Random;
|
using cpputils::Random;
|
||||||
namespace bf = boost::filesystem;
|
namespace bf = boost::filesystem;
|
||||||
|
using namespace cpputils::logging;
|
||||||
|
|
||||||
namespace cryfs {
|
namespace cryfs {
|
||||||
|
|
||||||
@ -106,17 +107,23 @@ void LocalStateMetadata::_serialize(ostream& stream) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LocalStateMetadata LocalStateMetadata::_deserialize(istream& stream) {
|
LocalStateMetadata LocalStateMetadata::_deserialize(istream& stream) {
|
||||||
ptree pt;
|
try {
|
||||||
read_json(stream, pt);
|
ptree pt;
|
||||||
|
read_json(stream, pt);
|
||||||
|
|
||||||
uint32_t myClientId = pt.get<uint32_t>("myClientId");
|
uint32_t myClientId = pt.get<uint32_t>("myClientId");
|
||||||
string encryptionKeySalt = pt.get<string>("encryptionKey.salt");
|
string encryptionKeySalt = pt.get<string>("encryptionKey.salt");
|
||||||
string encryptionKeyDigest = pt.get<string>("encryptionKey.hash");
|
string encryptionKeyDigest = pt.get<string>("encryptionKey.hash");
|
||||||
|
|
||||||
return LocalStateMetadata(myClientId, Hash{
|
return LocalStateMetadata(myClientId, Hash{
|
||||||
/*.digest = */ cpputils::hash::Digest::FromString(encryptionKeyDigest),
|
/*.digest = */ cpputils::hash::Digest::FromString(encryptionKeyDigest),
|
||||||
/*.salt = */ cpputils::hash::Salt::FromString(encryptionKeySalt)
|
/*.salt = */ cpputils::hash::Salt::FromString(encryptionKeySalt)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
LOG(ERR, "Error loading LocalStateMetadata");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user