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

Commit72eff15

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

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

‎cmd/coder/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (cmd *syncCmd) Spec() cli.CommandSpec {
2727
}
2828

2929
func (cmd*syncCmd)RegisterFlags(fl*pflag.FlagSet) {
30-
fl.BoolVarP(&cmd.init,"init","i",false,"doinititial transfer and exit")
30+
fl.BoolVarP(&cmd.init,"init","i",false,"doinitial transfer and exit")
3131
}
3232

3333
// See https://lxadm.com/Rsync_exit_codes#List_of_standard_rsync_exit_codes.

‎internal/sync/sync.go

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

74-
func (sSync)remoteRm(ctx context.Context,remotestring)error {
74+
func (sSync)remoteCmd(ctx context.Context,progstring,args...string)error {
7575
conn,err:=s.Client.DialWsep(ctx,s.Env)
7676
iferr!=nil {
7777
returnerr
@@ -80,8 +80,8 @@ func (s Sync) remoteRm(ctx context.Context, remote string) error {
8080

8181
execer:=wsep.RemoteExecer(conn)
8282
process,err:=execer.Start(ctx, wsep.Command{
83-
Command:"rm",
84-
Args:[]string{"-rf",remote},
83+
Command:prog,
84+
Args:args,
8585
})
8686
iferr!=nil {
8787
returnerr
@@ -91,7 +91,7 @@ func (s Sync) remoteRm(ctx context.Context, remote string) error {
9191

9292
err=process.Wait()
9393
ifcode,ok:=err.(wsep.ExitError);ok {
94-
returnfmt.Errorf("rm exit status: %v",code)
94+
returnfmt.Errorf("%s exit status: %v",prog,code)
9595
}
9696
iferr!=nil {
9797
returnxerrors.Errorf("execution failure: %w",err)
@@ -144,7 +144,7 @@ func (s Sync) handleDelete(localPath string) error {
144144
ctx,cancel:=context.WithTimeout(context.Background(),time.Minute)
145145
defercancel()
146146

147-
returns.remoteRm(ctx,s.convertPath(localPath))
147+
returns.remoteCmd(ctx,"rm","-rf",s.convertPath(localPath))
148148
}
149149

150150
func (sSync)handleRename(localPathstring)error {
@@ -260,6 +260,11 @@ func (s Sync) Run() error {
260260
}
261261
defernotify.Stop(events)
262262

263+
ctx,cancel:=context.WithTimeout(context.Background(),time.Minute)
264+
defercancel()
265+
266+
s.remoteCmd(ctx,"mkdir","-p",s.RemoteDir)
267+
263268
ap:=activity.NewPusher(s.Client,s.Env.ID,activityName)
264269
ap.Push()
265270

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp