1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Diagnostics ;
3
4
using System . Linq ;
4
5
using System . Reactive . Concurrency ;
@@ -56,6 +57,7 @@ public JsonIndexManager(
56
57
this . writer . InfoStream . Subscribe ( infoStream ) ;
57
58
58
59
Tracker = new IngestProgressTracker ( ) ;
60
+
59
61
jsonDocumentSource . DocumentChanges . ForEachAsync ( CaptureChange ) ;
60
62
jsonDocumentSource . InfoStream . Subscribe ( infoStream ) ;
61
63
jsonDocumentSource . Initialized . Subscribe ( Tracker . SetInitialized ) ;
@@ -71,6 +73,7 @@ public JsonIndexManager(
71
73
72
74
public async Task RunAsync ( )
73
75
{
76
+ index . Storage . Delete ( ) ;
74
77
bool restoredFromSnapshot = await RestoreSnapshotAsync ( ) . ConfigureAwait ( false ) ;
75
78
infoStream . WriteInfo ( $ "Index restored from a snapshot: { restoredFromSnapshot } .") ;
76
79
@@ -110,7 +113,6 @@ public Task UpdateGenerationAsync(string area, long generation)
110
113
return Task . CompletedTask ;
111
114
}
112
115
113
-
114
116
/// <summary>
115
117
/// Stops the underlying <see cref="IJsonDocumentSource"/>, deletes it's storage,
116
118
/// requests reset of the underlying <see cref="IJsonDocumentSource"/> and then starts it again.
@@ -122,7 +124,7 @@ public async Task ResetIndexAsync()
122
124
await jsonDocumentSource . ResetAsync ( ) . ConfigureAwait ( false ) ;
123
125
await jsonDocumentSource . StartAsync ( ) . ConfigureAwait ( false ) ;
124
126
}
125
-
127
+
126
128
private void CaptureChange ( IJsonDocumentSourceEvent sourceEvent )
127
129
{
128
130
try
@@ -142,7 +144,6 @@ private void CaptureChange(IJsonDocumentSourceEvent sourceEvent)
142
144
writer . Update ( updated . Document ) ;
143
145
break ;
144
146
}
145
-
146
147
changesStream . Publish ( sourceEvent ) ;
147
148
}
148
149
catch ( Exception ex )
0 commit comments