diff --git a/src/cryfs/filesystem/CryDevice.cpp b/src/cryfs/filesystem/CryDevice.cpp index 1298ab5f..0f0b0895 100644 --- a/src/cryfs/filesystem/CryDevice.cpp +++ b/src/cryfs/filesystem/CryDevice.cpp @@ -29,6 +29,7 @@ using fspp::fuse::FuseErrnoException; using blockstore::BlockStore; using blockstore::Key; using blockstore::encrypted::EncryptedBlockStore; +using blobstore::BlobStore; using blobstore::onblocks::BlobStoreOnBlocks; using blobstore::onblocks::BlobOnBlocks; using blockstore::caching::CachingBlockStore; @@ -63,7 +64,7 @@ unique_ref CryDevice::Crea auto blobStore = CreateBlobStore(std::move(blockStore), configFile, myClientId); #ifndef CRYFS_NO_COMPATIBILITY - auto fsBlobStore = FsBlobStore::migrateIfNeeded(std::move(blobStore), Key::FromString(configFile->config()->RootBlob())); + auto fsBlobStore = MigrateOrCreateFsBlobStore(std::move(blobStore), configFile); #else auto fsBlobStore = make_unique_ref(std::move(blobStore)); #endif @@ -75,6 +76,16 @@ unique_ref CryDevice::Crea ); } +#ifndef CRYFS_NO_COMPATIBILITY +unique_ref CryDevice::MigrateOrCreateFsBlobStore(unique_ref blobStore, CryConfigFile *configFile) { + string rootBlobKey = configFile->config()->RootBlob(); + if ("" == rootBlobKey) { + return make_unique_ref(std::move(blobStore)); + } + return FsBlobStore::migrateIfNeeded(std::move(blobStore), Key::FromString(rootBlobKey)); +} +#endif + unique_ref CryDevice::CreateBlobStore(unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId) { auto versionCountingEncryptedBlockStore = CreateVersionCountingEncryptedBlockStore(std::move(blockStore), configFile, myClientId); // Create versionCountingEncryptedBlockStore not in the same line as BlobStoreOnBlocks, because it can modify BlocksizeBytes diff --git a/src/cryfs/filesystem/CryDevice.h b/src/cryfs/filesystem/CryDevice.h index ddeb8441..de0ee069 100644 --- a/src/cryfs/filesystem/CryDevice.h +++ b/src/cryfs/filesystem/CryDevice.h @@ -50,6 +50,9 @@ private: blockstore::Key GetOrCreateRootKey(CryConfigFile *config); blockstore::Key CreateRootBlobAndReturnKey(); static cpputils::unique_ref CreateFsBlobStore(cpputils::unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId); +#ifndef CRYFS_NO_COMPATIBILITY + static cpputils::unique_ref MigrateOrCreateFsBlobStore(cpputils::unique_ref blobStore, CryConfigFile *configFile); +#endif static cpputils::unique_ref CreateBlobStore(cpputils::unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId); static cpputils::unique_ref CreateVersionCountingEncryptedBlockStore(cpputils::unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId); static cpputils::unique_ref CreateEncryptedBlockStore(const CryConfig &config, cpputils::unique_ref baseBlockStore);