Skip to content

Commit

Permalink
escape filepaths in markup'ed lines
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeFZ committed Aug 18, 2024
1 parent 7c0c12b commit 7a8ba7d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Twodump/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ string ReplacePathSeparators(string path) =>
}
else
{
var escapedFilename = Markup.Escape(filename);
if ((info.Flags & FileFlags.FailedToRead) != 0)
{
AnsiConsole.MarkupLine($"[red bold]Failed to transfer {filename}.[/]");
AnsiConsole.MarkupLine($"[red bold]Failed to transfer {escapedFilename}.[/]");
continue;
}
fileCount++;
totalFileSize += info.FileSize;
var task = ctx.AddTask($"[white bold]{filename}[/]", true, info.FileSize);
var task = ctx.AddTask($"[white bold]{escapedFilename}[/]", true, info.FileSize);
// Just for good measure
var fullPath = Path.GetFullPath(filename);
Expand All @@ -116,15 +119,15 @@ string ReplacePathSeparators(string path) =>
// but upstream spectre.console does not currently provide an API for this.
// task.RemoveTask(task); I implemented this myself and it did solve the issue
AnsiConsole.MarkupLine($@"[white bold]Transferred[/] [grey italic]{filename}[/] [white bold]in[/] [green bold]{task.ElapsedTime:mm\m\ ss\s}.[/]");
AnsiConsole.MarkupLineInterpolated($@"[white bold]Transferred[/] [grey italic]{escapedFilename}[/] [white bold]in[/] [green bold]{task.ElapsedTime:mm\m\ ss\s}.[/]");
File.SetCreationTime(filename, DateTime.FromFileTime(info.LastWriteTime));
}
}
stopwatch.Stop();
AnsiConsole.MarkupLine($@"[green bold]Successfully[/] transferred {fileCount} files, totalling {totalFileSize} bytes, in {stopwatch.Elapsed:h\h\ mm\m\ ss\s}.");
AnsiConsole.MarkupLineInterpolated($@"[green bold]Successfully[/] transferred {fileCount} files, totalling {totalFileSize} bytes, in {stopwatch.Elapsed:h\h\ mm\m\ ss\s}.");
ctx.Refresh();
}
Expand Down

0 comments on commit 7a8ba7d

Please sign in to comment.