Skip to content

Commit

Permalink
begin caching original file snapshots
Browse files Browse the repository at this point in the history
ref #464
  • Loading branch information
collinbarrett committed Oct 26, 2018
1 parent d6a1a6b commit ebc9782
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/FilterLists.Services/Snapshot/Snapshot.cs
Expand Up @@ -211,6 +211,19 @@ private async Task GetLinesFromStream(Stream stream)
string line;
while ((line = await streamReader.ReadLineAsync()) != null)
lines.AddIfNotNullOrEmpty(line.Trim());
stream.Position = 0;
await SaveOriginalFile(stream);
}
}

private async Task SaveOriginalFile(Stream stream)
{
var fileName = Path.Combine("snapshots", List.Id.ToString(),
BitConverter.ToString(SnapEntity.Md5Checksum).Replace("-", "") + ".txt");
new FileInfo(fileName).Directory?.Create();
using (var fileStream = File.Create(fileName))
{
await stream.CopyToAsync(fileStream);
}
}

Expand Down

0 comments on commit ebc9782

Please sign in to comment.