Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit 366561f

Browse files
committed
Download new code-server only if file differs
1 parent 1aa7091 commit 366561f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

main.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"path/filepath"
1313
"runtime"
1414
"strconv"
15-
"strings"
1615
"time"
1716

1817
"golang.org/x/xerrors"
@@ -47,7 +46,7 @@ More info: https://github.com/codercom/sshcode
4746

4847
dir := flag.Arg(1)
4948
if dir == "" {
50-
dir = "\\~"
49+
dir = "~"
5150
}
5251

5352
flog.Info("ensuring code-server is updated...")
@@ -59,15 +58,20 @@ More info: https://github.com/codercom/sshcode
5958
"-tt",
6059
host,
6160
`/bin/bash -c 'set -euxo pipefail || exit 1
62-
mkdir -p ~/bin
6361
wget -q https://codesrv-ci.cdr.sh/latest-linux -O `+codeServerPath+`
64-
chmod +x `+codeServerPath+`
6562
mkdir -p ~/.local/share/code-server
63+
cd `+filepath.Dir(codeServerPath)+`
64+
wget -N https://codesrv-ci.cdr.sh/latest-linux
65+
[ -f `+codeServerPath+` ] && rm `+codeServerPath+`
66+
ln latest-linux `+codeServerPath+`
67+
chmod +x `+codeServerPath+`
6668
'`,
6769
)
68-
output, err := sshCmd.CombinedOutput()
70+
sshCmd.Stdout = os.Stdout
71+
sshCmd.Stderr = os.Stderr
72+
err := sshCmd.Run()
6973
if err != nil {
70-
flog.Fatal("failed to update code-server: %v: %s", err, output)
74+
flog.Fatal("failed to update code-server: %v", err)
7175
}
7276

7377
if !(*skipSyncFlag) {
@@ -93,9 +97,6 @@ mkdir -p ~/.local/share/code-server
9397
flog.Fatal("failed to find available port: %v", err)
9498
}
9599

96-
// Escaped so interpreted by the remote shell, not local.
97-
dir = strings.Replace(dir, "~", "\\~", 1)
98-
99100
sshCmdStr := fmt.Sprintf("ssh -tt -q -L %v %v %v 'cd %v; %v --host 127.0.0.1 --allow-http --no-auth --port=%v'",
100101
localPort+":localhost:"+localPort, *sshFlags, host, dir, codeServerPath, localPort,
101102
)

0 commit comments

Comments
 (0)