mirror of https://github.com/databricks/cli.git
[DECO-553] Escape file path strings in URL (#228)
Tested manually Before: ``` shreyas.goenka@THW32HFW6T test-dbx % bricks sync --full . /Repos/shreyas.goenka@databricks.com/test-dbx 2023/02/27 19:51:17 [INFO] Remote file sync location: /Repos/shreyas.goenka@databricks.com/test-dbx 2023/02/27 19:51:17 [INFO] Action: PUT: #foo.py, .gitignore 2023/02/27 19:51:19 [INFO] Uploaded .gitignore Error: Creating file failed. An item with path /Repos/shreyas.goenka@databricks.com/test-dbx already exists ``` After: ``` shreyas.goenka@THW32HFW6T test-dbx % bricks sync --full . /Repos/shreyas.goenka@databricks.com/test-dbx 2023/02/27 19:51:46 [INFO] Remote file sync location: /Repos/shreyas.goenka@databricks.com/test-dbx 2023/02/27 19:51:46 [INFO] Action: PUT: #foo.py, .gitignore 2023/02/27 19:51:47 [INFO] Uploaded .gitignore 2023/02/27 19:51:47 [INFO] Uploaded #foo.py ```
This commit is contained in:
parent
2615d66945
commit
5166055efb
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -61,9 +62,8 @@ func (r *RepoFiles) writeRemote(ctx context.Context, relativePath string, conten
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
apiPath := fmt.Sprintf(
|
escapedPath := url.QueryEscape(strings.TrimLeft(remotePath, "/"))
|
||||||
"/api/2.0/workspace-files/import-file/%s?overwrite=true",
|
apiPath := fmt.Sprintf("/api/2.0/workspace-files/import-file/%s?overwrite=true", escapedPath)
|
||||||
strings.TrimLeft(remotePath, "/"))
|
|
||||||
|
|
||||||
err = apiClient.Do(ctx, http.MethodPost, apiPath, content, nil)
|
err = apiClient.Do(ctx, http.MethodPost, apiPath, content, nil)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue