@@ -1048,17 +1048,21 @@ code CLASS::restore(const event_handler& handler) NOEXCEPT
10481048 static const auto heads = configuration_.path / schema::dir::heads;
10491049 static const auto primary = configuration_.path / schema::dir::primary;
10501050 static const auto secondary = configuration_.path / schema::dir::secondary;
1051+ static const auto temporary = configuration_.path / schema::dir::temporary;
10511052
10521053 handler (event_t ::recover_snapshot, table_t ::store);
10531054
1055+ // Clean up any residual /temporary.
1056+ file::clear_directory (temporary);
1057+ file::remove (temporary);
1058+
10541059 if (file::is_directory (primary))
10551060 {
10561061 // Clear invalid /heads, recover from /primary, clone to /primary.
10571062 ec = file::clear_directory_ex (heads);
10581063 if (!ec) ec = file::remove_ex (heads);
10591064 if (!ec) ec = file::rename_ex (primary, heads);
10601065 if (!ec) ec = file::copy_directory_ex (heads, primary);
1061- if (ec) /* bool */ file::remove_ex (primary);
10621066 }
10631067 else if (file::is_directory (secondary))
10641068 {
@@ -1067,7 +1071,6 @@ code CLASS::restore(const event_handler& handler) NOEXCEPT
10671071 if (!ec) ec = file::remove_ex (heads);
10681072 if (!ec) ec = file::rename_ex (secondary, heads);
10691073 if (!ec) ec = file::copy_directory_ex (heads, primary);
1070- if (ec) /* bool */ file::remove_ex (secondary);
10711074 }
10721075 else
10731076 {
0 commit comments