feat(archival): left pad archive filenames for better sorting

This commit is contained in:
Collin M. Barrett 2020-09-19 06:55:43 -05:00
parent f65f7cb359
commit 6dd066f82d

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
@ -90,7 +91,7 @@ private IFileToArchive GetFileToArchive(
CancellationToken cancellationToken)
{
var segmentsAsync = GetSegmentsAsync(segmentUrls, cancellationToken);
var target = new FileInfo($"{listId}.txt");
var target = new FileInfo($"{listId.ToString(CultureInfo.InvariantCulture).PadLeft(5, '0')}.txt");
return new FileToArchive(segmentsAsync, target);
}
@ -98,7 +99,7 @@ private async IAsyncEnumerable<IFileToArchiveSegment> GetSegmentsAsync(
IEnumerable<ListDetailsViewUrlVm> segmentUrls,
[EnumeratorCancellation] CancellationToken cancellationToken)
{
foreach (var segment in segmentUrls)
foreach (var segment in segmentUrls)
{
var sourceFileName = Uri.UnescapeDataString(segment.Url.Segments.Last());
var sourceExtension = Path.GetExtension(sourceFileName);