Skip to content

Commit

Permalink
Merge pull request #80 from testit-tms/hotfix/TMS-29208-incorrect-imp…
Browse files Browse the repository at this point in the history
…orter-resultpath

TMS-29208: fix resultPath mixing by Path.Combine on windows
  • Loading branch information
taipoxinous authored Oct 22, 2024
2 parents bb2a846 + 0da5bc5 commit 8e90e59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Migrators/Importer/Services/ParserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public ParserService(ILogger<ParserService> logger, IConfiguration configuration
if (string.IsNullOrEmpty(resultPath))
{
throw new ArgumentException("resultPath is not set");
}
if (resultPath.Contains('/') && Path.DirectorySeparatorChar == '\\')
{
resultPath = resultPath.Replace("/", "\\");
}
if (resultPath.Contains('\\') && Path.DirectorySeparatorChar == '/')
{
throw new ArgumentException("resultPath separators on your OS should be /");
}

_resultPath = resultPath;
Expand Down Expand Up @@ -91,7 +99,7 @@ public async Task<TestCase> GetTestCase(Guid guid)

public Task<FileStream> GetAttachment(Guid guid, string fileName)
{
var filePath = Path.Combine(_resultPath, guid.ToString(), fileName);
var filePath = Path.Combine(_resultPath, guid.ToString(), fileName);

if (!File.Exists(filePath))
{
Expand Down
8 changes: 8 additions & 0 deletions Migrators/JsonWriter/WriteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public WriteService(ILogger<WriteService> logger, IConfiguration configuration)
if (string.IsNullOrEmpty(path))
{
throw new ArgumentException("Result path is not specified");
}
if (path.Contains('/') && Path.DirectorySeparatorChar == '\\')
{
path = path.Replace("/", "\\");
}
if (path.Contains('\\') && Path.DirectorySeparatorChar == '/')
{
throw new ArgumentException("resultPath separators on your OS should be /");
}

_path = Path.GetFullPath(path);
Expand Down

0 comments on commit 8e90e59

Please sign in to comment.