|
|
@@ -31,8 +31,8 @@ namespace craftlab::fakeraid
|
|
|
void CopyItems(const std::vector<CopyInstruction>& itemsToCopy) const override;
|
|
|
|
|
|
private:
|
|
|
- void ListFiles(FileAndSumListByRepositoryIndex& result, const PathParts& currentDir, bool* threadStopping =nullptr);
|
|
|
- FileAndSumList ListFiles(const std::string& root, const PathParts& path, int repositoryIndex, bool* threadStopping =nullptr);
|
|
|
+ void ListFiles(FileAndSumListByRepositoryIndex& result, const PathParts& currentDir, std::string* lastFileScanned =nullptr, bool* threadStopping =nullptr);
|
|
|
+ FileAndSumList ListFiles(const std::string& root, const PathParts& path, int repositoryIndex, std::string* lastFileScanned =nullptr, bool* threadStopping =nullptr);
|
|
|
|
|
|
void CopyItem(const CopyInstruction& dst) const;
|
|
|
|
|
|
@@ -114,7 +114,7 @@ void Engine::Cd(const std::string& dirName)
|
|
|
currentDir.push_back(dirName);
|
|
|
}
|
|
|
|
|
|
-FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::string>& wd, int repositoryIndex, bool* threadStopping)
|
|
|
+FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::string>& wd, int repositoryIndex, std::string* lastFileScanned, bool* threadStopping)
|
|
|
{
|
|
|
FileAndSumList result {};
|
|
|
const std::string path = BuildCurrentDirPath(root, wd);
|
|
|
@@ -133,6 +133,7 @@ FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::
|
|
|
{
|
|
|
bool isDirectory = false;
|
|
|
bool isFile = false;
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
isDirectory = file.is_directory();
|
|
|
@@ -148,6 +149,9 @@ FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::
|
|
|
fileInfos.directory = wd;
|
|
|
fileInfos.repositoryIndex = repositoryIndex;
|
|
|
|
|
|
+ if (nullptr != lastFileScanned)
|
|
|
+ *lastFileScanned = BuildCurrentDirPath(fileInfos);
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
cryptoEngine.Compute(path, fileInfos);
|
|
|
@@ -163,12 +167,12 @@ FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-void Engine::ListFiles(FileAndSumListByRepositoryIndex& result, const std::deque<std::string>& currentDir, bool* threadStopping)
|
|
|
+void Engine::ListFiles(FileAndSumListByRepositoryIndex& result, const std::deque<std::string>& currentDir, std::string* lastFileScanned, bool* threadStopping)
|
|
|
{
|
|
|
int index = 0;
|
|
|
for (const auto& i : rootPaths)
|
|
|
{
|
|
|
- const FileAndSumList files = ListFiles(i, currentDir, index++, threadStopping);
|
|
|
+ const FileAndSumList files = ListFiles(i, currentDir, index++, lastFileScanned, threadStopping);
|
|
|
result.FileAndSumListByRepositoryIndex.push_back(files);
|
|
|
for (const FileAndSum& file : files)
|
|
|
result.FileList[BuildCurrentDirPath(file)] = file;
|
|
|
@@ -192,7 +196,7 @@ void Engine::ListFilesRecur(FileAndSumListByRepositoryIndex* result, bool* threa
|
|
|
{
|
|
|
FileAndSumListByRepositoryIndex newItems;
|
|
|
const PathParts currentPath = itemsToDo.front();
|
|
|
- ListFiles(newItems, currentPath, threadStopping);
|
|
|
+ ListFiles(newItems, currentPath, &result->lastInsertedFilename, threadStopping);
|
|
|
itemsToDo.pop_front();
|
|
|
std::copy(newItems.FileAndSumListByRepositoryIndex.begin(), newItems.FileAndSumListByRepositoryIndex.end(), std::back_inserter(result->FileAndSumListByRepositoryIndex));
|
|
|
for (const auto& file : newItems.FileList)
|