anshdadhich commited on
Commit
8eb8349
·
verified ·
1 Parent(s): 0e209a3

Upload FastSeekWpf/MainWindow.xaml.cs

Browse files
Files changed (1) hide show
  1. FastSeekWpf/MainWindow.xaml.cs +20 -22
FastSeekWpf/MainWindow.xaml.cs CHANGED
@@ -196,37 +196,35 @@ public partial class MainWindow : Window, INotifyPropertyChanged
196
  ScanResult? scan = null;
197
  string method = "direct";
198
 
199
- try
 
 
200
  {
201
- scan = reader.ScanDirect();
202
  Logger.Log($"Direct scan OK for {drive.Letter}");
203
  }
204
- catch (Exception ex1)
205
  {
206
- Logger.Log($"Direct scan failed for {drive.Letter}: {ex1.Message}");
207
- method = "fallback";
208
- }
209
-
210
- if (scan == null)
211
- {
212
- try
213
  {
214
- scan = reader.Scan();
215
- Logger.Log($"Fallback scan OK for {drive.Letter}");
216
  method = "fallback";
217
- }
218
- catch (Exception ex2)
219
- {
220
- Logger.Log($"Fallback scan failed for {drive.Letter}: {ex2.Message}");
221
- Dispatcher.Invoke(() => StatusText.Text = $"Scan failed for {drive.Letter}");
222
- continue;
223
  }
224
  }
225
 
226
- _index.PopulateFromScan(scan, drive.Root);
227
- totalRecords += scan.Records.Count;
228
- Logger.Log($"Scanned {drive.Letter}: {scan.Records.Count} files ({method})");
229
- Dispatcher.Invoke(() => StatusText.Text = $"Scanned {drive.Letter}: {scan.Records.Count:N0} files");
 
 
 
 
 
 
 
 
230
  }
231
  catch (Exception ex)
232
  {
 
196
  ScanResult? scan = null;
197
  string method = "direct";
198
 
199
+ // Try direct first (matches Rust scan_direct())
200
+ scan = reader.ScanDirect();
201
+ if (scan != null)
202
  {
 
203
  Logger.Log($"Direct scan OK for {drive.Letter}");
204
  }
205
+ else
206
  {
207
+ Logger.Log($"Direct scan unavailable for {drive.Letter}, trying fallback");
208
+ scan = reader.Scan();
209
+ if (scan != null)
 
 
 
 
210
  {
 
 
211
  method = "fallback";
212
+ Logger.Log($"Fallback scan OK for {drive.Letter}");
 
 
 
 
 
213
  }
214
  }
215
 
216
+ if (scan != null && scan.Records.Count > 0)
217
+ {
218
+ _index.PopulateFromScan(scan, drive.Root);
219
+ totalRecords += scan.Records.Count;
220
+ Logger.Log($"Scanned {drive.Letter}: {scan.Records.Count} files ({method})");
221
+ Dispatcher.Invoke(() => StatusText.Text = $"Scanned {drive.Letter}: {scan.Records.Count:N0} files");
222
+ }
223
+ else
224
+ {
225
+ Logger.Log($"Scan returned 0 records for {drive.Letter}");
226
+ Dispatcher.Invoke(() => StatusText.Text = $"Scan failed for {drive.Letter}");
227
+ }
228
  }
229
  catch (Exception ex)
230
  {