Merge remote-tracking branch 'origin/aqua/safe-filename-collide-dotdot' into aqua/store-filename-ipa
This commit is contained in:
commit
b906d98ed5
3 changed files with 11 additions and 3 deletions
|
|
@ -38,6 +38,12 @@ public static class StoreFileName
|
|||
return safe;
|
||||
}
|
||||
|
||||
// "nul.x-<hash>" still has the device stem "nul"; the underscore moves the whole name off it.
|
||||
if (IsDeviceStem(safe))
|
||||
{
|
||||
safe = "_" + safe;
|
||||
}
|
||||
|
||||
var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(id)))[..HashLength].ToLowerInvariant();
|
||||
return $"{safe}-{hash}";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ public sealed class StoreFileNameTests
|
|||
var name = StoreFileName.From(id);
|
||||
Assert.NotEqual(id.ToLowerInvariant(), name.ToLowerInvariant());
|
||||
Assert.Matches("-[0-9a-f]{16}$", name);
|
||||
var stem = name.Split('.')[0].TrimEnd(' ');
|
||||
Assert.DoesNotMatch("^(?i:con|prn|aux|nul|com[0-9]|lpt[0-9])$", stem);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ static async Task SongScoreAsync(Dictionary<string, string> options)
|
|||
{
|
||||
var startedAt = DateTimeOffset.UtcNow;
|
||||
var startedStamp = Stopwatch.GetTimestamp();
|
||||
var safeCandidateId = SafeName(candidate.CandidateId);
|
||||
var safeCandidateId = StoreFileName.From(candidate.CandidateId);
|
||||
var candidateDir = Path.Combine(candidateRoot, safeCandidateId);
|
||||
var audioDir = Path.Combine(candidateDir, "audio");
|
||||
Directory.CreateDirectory(audioDir);
|
||||
|
|
@ -2658,10 +2658,10 @@ static bool IsOfficialMusicArtifactPath(string path)
|
|||
}
|
||||
|
||||
static string CandidatePatchPath(SongSummaryRow row) =>
|
||||
Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", SafeName(row.CandidateId), "candidate.aqua");
|
||||
Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", StoreFileName.From(row.CandidateId), "candidate.aqua");
|
||||
|
||||
static string CandidateAnalysisPath(SongSummaryRow row) =>
|
||||
Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", SafeName(row.CandidateId), "candidate-analysis.md");
|
||||
Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "song-candidates", StoreFileName.From(row.CandidateId), "candidate-analysis.md");
|
||||
|
||||
static string EvaluatorReportPath(SongSummaryRow row) =>
|
||||
Path.Combine(Path.GetDirectoryName(row.SummaryPath)!, "evaluator-report.md");
|
||||
|
|
|
|||
Loading…
Reference in a new issue