mirror of
https://github.com/coder/coder.git
synced 2025-07-23 21:32:07 +00:00
fix: Fix template create with sub-folders on Windows (#4548)
On Windows, files in tar archives were stored with Windows path-separators resulting in them being individual files as opposed to contained in a folder. This commit ensures Unix-based paths (slash) are being used inside tar archives. Exmple of previous output: ``` /tmp/provisionerd673501182/images: /tmp/provisionerd673501182/: README.md images images\base.Dockerfile images\java.Dockerfile images\node.Dockerfile main.tf ``` Fixes #2815
This commit is contained in:
committed by
GitHub
parent
88f7505fdf
commit
19d7281daf
@ -1,7 +1,6 @@
|
||||
package provisionersdk_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@ -59,6 +58,7 @@ func TestTar(t *testing.T) {
|
||||
}}
|
||||
for _, file := range files {
|
||||
newDir := dir
|
||||
file.Name = filepath.FromSlash(file.Name)
|
||||
if filepath.Base(file.Name) != file.Name {
|
||||
newDir = filepath.Join(newDir, filepath.Dir(file.Name))
|
||||
err := os.MkdirAll(newDir, 0755)
|
||||
@ -70,7 +70,6 @@ func TestTar(t *testing.T) {
|
||||
_ = tmpFile.Close()
|
||||
file.Name, err = filepath.Rel(dir, tmpFile.Name())
|
||||
require.NoError(t, err)
|
||||
fmt.Printf("rel")
|
||||
}
|
||||
content, err := provisionersdk.Tar(dir, 1024)
|
||||
require.NoError(t, err)
|
||||
|
Reference in New Issue
Block a user