diff --git a/src/cli/Cli.cpp b/src/cli/Cli.cpp index cff37164..aacb5e15 100644 --- a/src/cli/Cli.cpp +++ b/src/cli/Cli.cpp @@ -61,7 +61,6 @@ using boost::chrono::milliseconds; //TODO Support files > 4GB //TODO Improve parallelity. //TODO Did deadlock in bonnie++ second run (in the create files sequentially) - maybe also in a later run or different step? -//TODO Improve error message when root blob wasn't found. //TODO Replace ASSERTs with other error handling when it is not a programming error but an environment influence (e.g. a block is missing) namespace cryfs { diff --git a/src/filesystem/CryDevice.cpp b/src/filesystem/CryDevice.cpp index f7c08ce3..dce1cde1 100644 --- a/src/filesystem/CryDevice.cpp +++ b/src/filesystem/CryDevice.cpp @@ -39,6 +39,7 @@ using cryfs::parallelaccessfsblobstore::FileBlobRef; using cryfs::parallelaccessfsblobstore::DirBlobRef; using cryfs::parallelaccessfsblobstore::SymlinkBlobRef; using cryfs::parallelaccessfsblobstore::FsBlobRef; +using namespace cpputils::logging; namespace bf = boost::filesystem; @@ -101,7 +102,10 @@ unique_ref CryDevice::LoadDirBlob(const bf::path &path) { unique_ref CryDevice::LoadBlob(const bf::path &path) { auto currentBlob = _fsBlobStore->load(_rootKey); - ASSERT(currentBlob != none, "rootDir not found"); + if (currentBlob == none) { + LOG(ERROR) << "Could not load root blob. Is the base directory accessible?"; + throw FuseErrnoException(EIO); + } for (const bf::path &component : path.relative_path()) { auto currentDir = dynamic_pointer_move(*currentBlob); @@ -142,13 +146,19 @@ unique_ref CryDevice::CreateSymlinkBlob(const bf::path &target) unique_ref CryDevice::LoadBlob(const blockstore::Key &key) { auto blob = _fsBlobStore->load(key); - ASSERT(blob != none, "Blob not found"); + if (blob == none) { + LOG(ERROR) << "Could not load blob " << key.ToString() << ". Is the root directory accessible?"; + throw FuseErrnoException(EIO); + } return std::move(*blob); } void CryDevice::RemoveBlob(const blockstore::Key &key) { auto blob = _fsBlobStore->load(key); - ASSERT(blob != none, "Blob not found"); + if (blob == none) { + LOG(ERROR) << "Could not load blob " << key.ToString() << ". Is the root directory accessible?"; + throw FuseErrnoException(EIO); + } _fsBlobStore->remove(std::move(*blob)); }