diff --git a/src/blockstore/implementations/integrity/IntegrityBlockStore2.cpp b/src/blockstore/implementations/integrity/IntegrityBlockStore2.cpp index 1b37b97b..06add856 100644 --- a/src/blockstore/implementations/integrity/IntegrityBlockStore2.cpp +++ b/src/blockstore/implementations/integrity/IntegrityBlockStore2.cpp @@ -3,6 +3,7 @@ #include "KnownBlockVersions.h" #include #include +#include using cpputils::Data; using cpputils::unique_ref; @@ -199,15 +200,16 @@ void IntegrityBlockStore2::forEachBlock(std::function ca void IntegrityBlockStore2::migrateFromBlockstoreWithoutVersionNumbers(BlockStore2 *baseBlockStore, const boost::filesystem::path &integrityFilePath, uint32_t myClientId) { SignalCatcher signalCatcher; - std::cout << "Migrating file system for integrity features. Please don't interrupt this process. This can take a while..." << std::flush; KnownBlockVersions knownBlockVersions(integrityFilePath, myClientId); - baseBlockStore->forEachBlock([&baseBlockStore, &knownBlockVersions, &signalCatcher] (const BlockId &blockId) { + uint64_t numProcessedBlocks = 0; + cpputils::ProgressBar progressbar("Migrating file system for integrity features. This can take a while...", baseBlockStore->numBlocks()); + baseBlockStore->forEachBlock([&] (const BlockId &blockId) { if (signalCatcher.signal_occurred()) { throw std::runtime_error("Caught signal"); } migrateBlockFromBlockstoreWithoutVersionNumbers(baseBlockStore, blockId, &knownBlockVersions); + progressbar.update(++numProcessedBlocks); }); - std::cout << "done" << std::endl; } void IntegrityBlockStore2::migrateBlockFromBlockstoreWithoutVersionNumbers(blockstore::BlockStore2* baseBlockStore, const blockstore::BlockId& blockId, KnownBlockVersions *knownBlockVersions) { diff --git a/src/cryfs/filesystem/fsblobstore/FsBlobStore.cpp b/src/cryfs/filesystem/fsblobstore/FsBlobStore.cpp index 754cc9a7..a7136f6b 100644 --- a/src/cryfs/filesystem/fsblobstore/FsBlobStore.cpp +++ b/src/cryfs/filesystem/fsblobstore/FsBlobStore.cpp @@ -3,6 +3,7 @@ #include "DirBlob.h" #include "SymlinkBlob.h" #include +#include #include using cpputils::unique_ref; @@ -42,15 +43,19 @@ boost::optional> FsBlobStore::load(const blockstore::BlockId auto fsBlobStore = make_unique_ref(std::move(blobStore)); - std::cout << "Migrating file system for conflict resolution features. Please don't interrupt this process. This can take a while..." << std::flush; - fsBlobStore->_migrate(std::move(*rootBlob), blockstore::BlockId::Null(), &signalCatcher); - std::cout << "done" << std::endl; + uint64_t migratedBlocks = 0; + cpputils::ProgressBar progressbar("Migrating file system for conflict resolution features. This can take a while...", fsBlobStore->numBlocks()); + fsBlobStore->_migrate(std::move(*rootBlob), blockstore::BlockId::Null(), &signalCatcher, [&] (uint32_t numNodes) { + migratedBlocks += numNodes; + progressbar.update(migratedBlocks); + }); return fsBlobStore; } - void FsBlobStore::_migrate(unique_ref node, const blockstore::BlockId &parentId, SignalCatcher* signalCatcher) { + void FsBlobStore::_migrate(unique_ref node, const blockstore::BlockId &parentId, SignalCatcher* signalCatcher, std::function perBlobCallback) { FsBlobView::migrate(node.get(), parentId); + perBlobCallback(node->numNodes()); if (FsBlobView::blobType(*node) == FsBlobView::BlobType::DIR) { DirBlob dir(std::move(node), _getLstatSize()); vector children; @@ -64,7 +69,7 @@ boost::optional> FsBlobStore::load(const blockstore::BlockId ASSERT(childEntry != none, "Couldn't load child, although it was returned as a child in the list."); auto childBlob = _baseBlobStore->load(childEntry->blockId()); ASSERT(childBlob != none, "Couldn't load child blob"); - _migrate(std::move(*childBlob), dir.blockId(), signalCatcher); + _migrate(std::move(*childBlob), dir.blockId(), signalCatcher, perBlobCallback); } } } diff --git a/src/cryfs/filesystem/fsblobstore/FsBlobStore.h b/src/cryfs/filesystem/fsblobstore/FsBlobStore.h index 30ed3aab..d55aa0dd 100644 --- a/src/cryfs/filesystem/fsblobstore/FsBlobStore.h +++ b/src/cryfs/filesystem/fsblobstore/FsBlobStore.h @@ -38,7 +38,7 @@ namespace cryfs { private: #ifndef CRYFS_NO_COMPATIBILITY - void _migrate(cpputils::unique_ref node, const blockstore::BlockId &parentId, cpputils::SignalCatcher* signalCatcher); + void _migrate(cpputils::unique_ref node, const blockstore::BlockId &parentId, cpputils::SignalCatcher* signalCatcher, std::function perBlobCallback); #endif std::function _getLstatSize();