IpaGestureExperiment: use StoreFileName, delete the last SafeFileName copy
Round and candidate ids in the IPA experiment bundle went through a private
sanitiser that mapped distinct ids ("a/b", "a-b") to one file and accepted
".." as a round id. They now go through the shared StoreFileName.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
81362a7013
commit
28e37f5cbb
2 changed files with 17 additions and 9 deletions
|
|
@ -108,7 +108,7 @@ public static class IpaGestureExperiment
|
|||
throw new ArgumentException("At least one experiment variant is required.", nameof(variants));
|
||||
}
|
||||
|
||||
var roundDirectory = Path.Combine(rootDirectory, SafeFileName(roundId));
|
||||
var roundDirectory = Path.Combine(rootDirectory, StoreFileName.From(roundId));
|
||||
var candidateDirectory = Path.Combine(roundDirectory, "candidates");
|
||||
var timelineDirectory = Path.Combine(roundDirectory, "timelines");
|
||||
Directory.CreateDirectory(candidateDirectory);
|
||||
|
|
@ -122,7 +122,7 @@ public static class IpaGestureExperiment
|
|||
{
|
||||
foreach (var variant in variantList)
|
||||
{
|
||||
var candidateId = SafeFileName($"{target.Id}-{variant.Id}");
|
||||
var candidateId = StoreFileName.From($"{target.Id}-{variant.Id}");
|
||||
var script = BuildCandidateScript(target, variant);
|
||||
var scriptPath = Path.Combine(candidateDirectory, $"{candidateId}.aqua");
|
||||
File.WriteAllText(scriptPath, script, Encoding.UTF8);
|
||||
|
|
@ -705,13 +705,6 @@ public static class IpaGestureExperiment
|
|||
private static string SafeDslName(string value) =>
|
||||
new(value.Select(character => char.IsLetterOrDigit(character) ? character : '_').ToArray());
|
||||
|
||||
private static string SafeFileName(string value)
|
||||
{
|
||||
var invalid = Path.GetInvalidFileNameChars().ToHashSet();
|
||||
var safe = new string(value.Select(character => invalid.Contains(character) || char.IsWhiteSpace(character) ? '-' : character).ToArray());
|
||||
return safe.Length == 0 ? "candidate" : safe;
|
||||
}
|
||||
|
||||
private static string Format(float value) =>
|
||||
value.ToString("0.######", CultureInfo.InvariantCulture);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue