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
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit92f3c77

Browse files
author
Russtopia
committed
coder sync fails if all dirs leading to sync remoteDir don't already exist
1 parent01cd4c5 commit92f3c77

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

‎internal/sync/sync.go

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,38 +71,7 @@ func (s Sync) syncPaths(delete bool, local, remote string) error {
7171
returnnil
7272
}
7373

74-
func (sSync)remoteMkDir()error {
75-
ctx,cancel:=context.WithTimeout(context.Background(),time.Minute)
76-
defercancel()
77-
78-
conn,err:=s.Client.DialWsep(ctx,s.Environment)
79-
iferr!=nil {
80-
returnerr
81-
}
82-
deferconn.Close(websocket.CloseNormalClosure,"")
83-
84-
execer:=wsep.RemoteExecer(conn)
85-
process,err:=execer.Start(ctx, wsep.Command{
86-
Command:"mkdir",
87-
Args: []string{"-p",s.RemoteDir},
88-
})
89-
iferr!=nil {
90-
returnerr
91-
}
92-
goio.Copy(os.Stdout,process.Stderr())
93-
goio.Copy(os.Stderr,process.Stdout())
94-
95-
err=process.Wait()
96-
ifcode,ok:=err.(wsep.ExitError);ok {
97-
returnfmt.Errorf("mkdir exit status: %v",code)
98-
}
99-
iferr!=nil {
100-
returnxerrors.Errorf("execution failure: %w",err)
101-
}
102-
returnnil
103-
}
104-
105-
func (sSync)remoteRm(ctx context.Context,remotestring)error {
74+
func (sSync)remoteCmd(ctx context.Context,progstring,args...string)error {
10675
conn,err:=s.Client.DialWsep(ctx,s.Env)
10776
iferr!=nil {
10877
returnerr
@@ -111,8 +80,8 @@ func (s Sync) remoteRm(ctx context.Context, remote string) error {
11180

11281
execer:=wsep.RemoteExecer(conn)
11382
process,err:=execer.Start(ctx, wsep.Command{
114-
Command:"rm",
115-
Args:[]string{"-rf",remote},
83+
Command:prog,
84+
Args:args,
11685
})
11786
iferr!=nil {
11887
returnerr
@@ -122,7 +91,7 @@ func (s Sync) remoteRm(ctx context.Context, remote string) error {
12291

12392
err=process.Wait()
12493
ifcode,ok:=err.(wsep.ExitError);ok {
125-
returnfmt.Errorf("rm exit status: %v",code)
94+
returnfmt.Errorf("%s exit status: %v",prog,code)
12695
}
12796
iferr!=nil {
12897
returnxerrors.Errorf("execution failure: %w",err)
@@ -175,7 +144,7 @@ func (s Sync) handleDelete(localPath string) error {
175144
ctx,cancel:=context.WithTimeout(context.Background(),time.Minute)
176145
defercancel()
177146

178-
returns.remoteRm(ctx,s.convertPath(localPath))
147+
returns.remoteCmd(ctx,"rm","-rf",s.convertPath(localPath))
179148
}
180149

181150
func (sSync)handleRename(localPathstring)error {
@@ -291,7 +260,10 @@ func (s Sync) Run() error {
291260
}
292261
defernotify.Stop(events)
293262

294-
s.remoteMkDir()
263+
ctx,cancel:=context.WithTimeout(context.Background(),time.Minute)
264+
defercancel()
265+
266+
s.remoteCmd(ctx,"mkdir","-p",s.RemoteDir)
295267

296268
ap:=activity.NewPusher(s.Client,s.Env.ID,activityName)
297269
ap.Push()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp