Prepare file reader loop

This commit is contained in:
Jöran Malek 2023-11-26 02:10:01 +01:00
parent 583ae506d2
commit de5556faea

View file

@ -6,8 +6,6 @@ using nietras.SeparatedValues;
using pdns_dhcp.Options; using pdns_dhcp.Options;
using Stl.Async;
namespace pdns_dhcp.Kea; namespace pdns_dhcp.Kea;
public abstract class KeaDhcpLeaseWatcher : IHostedService public abstract class KeaDhcpLeaseWatcher : IHostedService
@ -19,6 +17,7 @@ public abstract class KeaDhcpLeaseWatcher : IHostedService
Options = FileOptions.SequentialScan, Options = FileOptions.SequentialScan,
Share = (FileShare)7, Share = (FileShare)7,
}; };
private readonly FileSystemWatcher _fsw; private readonly FileSystemWatcher _fsw;
private readonly string _leaseFile; private readonly string _leaseFile;
private Channel<FileSystemEventArgs>? _eventChannel; private Channel<FileSystemEventArgs>? _eventChannel;
@ -135,7 +134,12 @@ public abstract class KeaDhcpLeaseWatcher : IHostedService
{ {
try try
{ {
using var fileStream = new FileStream(Options.Leases, _leaseFileStreamOptions); using var streamReader = new StreamReader(Options.Leases, _leaseFileStreamOptions);
using var reader = Sep.Reader().From(streamReader);
while (!stoppingToken.IsCancellationRequested)
{
}
} }
catch { } catch { }
} }