Bring out MigrateBlocks to their own function (this accepts a block folder.)
MODIFY
WalletWasabi/Wallets/FileSystemBlockRepository.cs
WalletWasabi/Wallets/FileSystemBlockRepository.cs
@@ -55,13 +55,41 @@ namespace WalletWasabi.Wallets
foreach (string wrongBlockFolderPath in wrongBlockFolderPaths.Where(x => Directory.Exists(x)))
{
- Logger.LogTrace($"Initiate migration of '{wrongBlockFolderPath}'");
+ MigrateBlocks(wrongBlockFolderPath);
+ }
+
+ if (Directory.Exists(wrongGlobalBlockFolderPath))
+ {
+ // If all networks successfully migrated, too, then delete the transactions folder, too.
+ if (!Directory.EnumerateFileSystemEntries(wrongGlobalBlockFolderPath).Any())
+ {
+ Directory.Delete(wrongGlobalBlockFolderPath, recursive: true);
+ Logger.LogInfo($"Deleted '{wrongGlobalBlockFolderPath}' folder.");
+ }
+ else
+ {
+ Logger.LogTrace($"Cannot delete '{wrongGlobalBlockFolderPath}' folder as it is not empty.");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.LogWarning("Backwards compatibility could not be ensured.");
+ Logger.LogWarning(ex);
+ }
+
+ Logger.LogTrace("<");
+ }
+
+ private void MigrateBlocks(string blockFolderPath)
+ {
+ Logger.LogTrace($"Initiate migration of '{blockFolderPath}'");
int cntSuccess = 0;
int cntRedundant = 0;
int cntFailure = 0;
- foreach (string oldBlockFilePath in Directory.EnumerateFiles(wrongBlockFolderPath))
+ foreach (string oldBlockFilePath in Directory.EnumerateFiles(blockFolderPath))
{
try
{
@@ -75,7 +103,7 @@ namespace WalletWasabi.Wallets
}
}
- Directory.Delete(wrongBlockFolderPath, recursive: true);
+ Directory.Delete(blockFolderPath, recursive: true);
if (cntSuccess > 0)
{
@@ -92,30 +120,7 @@ namespace WalletWasabi.Wallets
Logger.LogDebug($"Failed to migrate {cntFailure} blocks to '{BlocksFolderPath}'.");
}
- Logger.LogInfo($"Deleted '{wrongBlockFolderPath}' folder.");
- }
-
- if (Directory.Exists(wrongGlobalBlockFolderPath))
- {
- // If all networks successfully migrated, too, then delete the transactions folder, too.
- if (!Directory.EnumerateFileSystemEntries(wrongGlobalBlockFolderPath).Any())
- {
- Directory.Delete(wrongGlobalBlockFolderPath, recursive: true);
- Logger.LogInfo($"Deleted '{wrongGlobalBlockFolderPath}' folder.");
- }
- else
- {
- Logger.LogTrace($"Cannot delete '{wrongGlobalBlockFolderPath}' folder as it is not empty.");
- }
- }
- }
- catch (Exception ex)
- {
- Logger.LogWarning("Backwards compatibility could not be ensured.");
- Logger.LogWarning(ex);
- }
-
- Logger.LogTrace("<");
+ Logger.LogInfo($"Deleted '{blockFolderPath}' folder.");
}
private void MigrateBlock(string blockFilePath, ref int cntSuccess, ref int cntRedundant)

Bring out MigrateBlocks to their own function (this accepts a block folder.)