From 670635a7d5ffa7f8495a5b5743efeb09bb5f9907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Sat, 21 May 2022 11:23:37 +0200 Subject: [PATCH 1/3] Normalize file paths to slashes --- trainings/files/read.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trainings/files/read.go b/trainings/files/read.go index 2cc418d..6a3a38b 100644 --- a/trainings/files/read.go +++ b/trainings/files/read.go @@ -23,7 +23,10 @@ func (f Files) ReadSolutionFiles(trainingRootFs afero.Fs, dir string) ([]*genpro return nil } - filesPaths = append(filesPaths, filePath) + // Normalize filepath to slashes + slashPath := filepath.ToSlash(filePath) + + filesPaths = append(filesPaths, slashPath) return nil }, ) From 57793baebf92e0b640fdecb6991aa6c392992568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Sat, 21 May 2022 11:51:51 +0200 Subject: [PATCH 2/3] Add proper slashes --- trainings/files/read.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trainings/files/read.go b/trainings/files/read.go index 6a3a38b..142909e 100644 --- a/trainings/files/read.go +++ b/trainings/files/read.go @@ -23,10 +23,7 @@ func (f Files) ReadSolutionFiles(trainingRootFs afero.Fs, dir string) ([]*genpro return nil } - // Normalize filepath to slashes - slashPath := filepath.ToSlash(filePath) - - filesPaths = append(filesPaths, slashPath) + filesPaths = append(filesPaths, filePath) return nil }, ) @@ -35,7 +32,7 @@ func (f Files) ReadSolutionFiles(trainingRootFs afero.Fs, dir string) ([]*genpro } var files []*genproto.File - for _, filePath := range filesPaths { + for _, filePath := range { content, err := afero.ReadFile(trainingRootFs, filePath) if err != nil { return nil, errors.Wrapf(err, "unable to read solution file %s", filePath) @@ -46,8 +43,11 @@ func (f Files) ReadSolutionFiles(trainingRootFs afero.Fs, dir string) ([]*genpro return nil, err } + // Normalize filepath to slashes + slashPath := filepath.ToSlash(relPath) + files = append(files, &genproto.File{ - Path: relPath, + Path: slashPath, Content: string(content), }) } From fcc9ed1c90fb6a3b601d9747cdef6db39520f4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Sat, 21 May 2022 11:52:29 +0200 Subject: [PATCH 3/3] Fix accidental change --- trainings/files/read.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trainings/files/read.go b/trainings/files/read.go index 142909e..661e65a 100644 --- a/trainings/files/read.go +++ b/trainings/files/read.go @@ -32,7 +32,7 @@ func (f Files) ReadSolutionFiles(trainingRootFs afero.Fs, dir string) ([]*genpro } var files []*genproto.File - for _, filePath := range { + for _, filePath := range filesPaths { content, err := afero.ReadFile(trainingRootFs, filePath) if err != nil { return nil, errors.Wrapf(err, "unable to read solution file %s", filePath)