Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6cee94

Browse files
committed
Fix requested changes
1 parente4770bb commitc6cee94

File tree

8 files changed

+28
-7
lines changed

8 files changed

+28
-7
lines changed

‎cli/clitest/clitest.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
var (
2525
// Used to ensure terminal output doesn't have anything crazy!
26+
// See: https://stackoverflow.com/a/29497680
2627
stripAnsi=regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))")
2728
)
2829

‎cli/projects.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func projects() *cobra.Command {
1717
cmd:=&cobra.Command{
1818
Use:"projects",
1919
Aliases: []string{"project"},
20-
Long:"Testing something",
2120
Example:`
2221
- Create a project for developers to create workspaces
2322

‎cli/workspacecreate.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ func workspaceCreate() *cobra.Command {
120120
_,_=fmt.Printf("Terraform: %s\n",log.Output)
121121
}
122122

123-
_,_=fmt.Printf("Created workspace! %s\n",name)
123+
// This command is WIP, and output will change!
124124

125+
_,_=fmt.Printf("Created workspace! %s\n",name)
125126
returnnil
126127
},
127128
}

‎coderd/files.go‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,18 @@ func (api *api) postFiles(rw http.ResponseWriter, r *http.Request) {
4040
return
4141
}
4242
hashBytes:=sha256.Sum256(data)
43-
file,err:=api.Database.InsertFile(r.Context(), database.InsertFileParams{
44-
Hash:hex.EncodeToString(hashBytes[:]),
43+
hash:=hex.EncodeToString(hashBytes[:])
44+
file,err:=api.Database.GetFileByHash(r.Context(),hash)
45+
iferr==nil {
46+
// The file already exists!
47+
render.Status(r,http.StatusOK)
48+
render.JSON(rw,r,UploadFileResponse{
49+
Hash:file.Hash,
50+
})
51+
return
52+
}
53+
file,err=api.Database.InsertFile(r.Context(), database.InsertFileParams{
54+
Hash:hash,
4555
CreatedBy:apiKey.UserID,
4656
CreatedAt:database.Now(),
4757
Mimetype:contentType,

‎coderd/files_test.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,15 @@ func TestPostFiles(t *testing.T) {
2727
_,err:=client.UploadFile(context.Background(),codersdk.ContentTypeTar,make([]byte,1024))
2828
require.NoError(t,err)
2929
})
30+
31+
t.Run("InsertAlreadyExists",func(t*testing.T) {
32+
t.Parallel()
33+
client:=coderdtest.New(t)
34+
_=coderdtest.CreateInitialUser(t,client)
35+
data:=make([]byte,1024)
36+
_,err:=client.UploadFile(context.Background(),codersdk.ContentTypeTar,data)
37+
require.NoError(t,err)
38+
_,err=client.UploadFile(context.Background(),codersdk.ContentTypeTar,data)
39+
require.NoError(t,err)
40+
})
3041
}

‎coderd/parameter/compute.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func Compute(ctx context.Context, db database.Store, scope ComputeScope, options
8888
continue
8989
}
9090
if_,ok:=compute.computedParameterByName[parameterSchema.Name];ok {
91-
// We already have a value! No need to useth default.
91+
// We already have a value! No need to usethe default.
9292
continue
9393
}
9494

‎coderd/provisionerjobs.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ func (api *api) provisionerJobLogsByID(rw http.ResponseWriter, r *http.Request)
170170
})
171171
iferrors.Is(err,sql.ErrNoRows) {
172172
err=nil
173-
provisionerJobLogs= []database.ProvisionerJobLog{}
174173
}
175174
iferr!=nil {
176175
httpapi.Write(rw,http.StatusInternalServerError, httpapi.Response{

‎codersdk/files.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (c *Client) UploadFile(ctx context.Context, contentType string, content []b
2020
return coderd.UploadFileResponse{},err
2121
}
2222
deferres.Body.Close()
23-
ifres.StatusCode!=http.StatusCreated {
23+
ifres.StatusCode!=http.StatusCreated&&res.StatusCode!=http.StatusOK{
2424
return coderd.UploadFileResponse{},readBodyAsError(res)
2525
}
2626
varresp coderd.UploadFileResponse

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp