forked from git-lfs/git-lfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-lfs.go
43 lines (35 loc) · 762 Bytes
/
git-lfs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"os"
"os/signal"
"sync"
"syscall"
"github.com/github/git-lfs/commands"
"github.com/github/git-lfs/lfs"
)
func main() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, os.Kill)
var once sync.Once
go func() {
for {
sig := <-c
once.Do(clearTempObjects)
fmt.Fprintf(os.Stderr, "\nExiting because of %q signal.\n", sig)
exitCode := 1
if sysSig, ok := sig.(syscall.Signal); ok {
exitCode = int(sysSig)
}
os.Exit(exitCode + 128)
}
}()
commands.Run()
lfs.LogHttpStats()
once.Do(clearTempObjects)
}
func clearTempObjects() {
if err := lfs.ClearTempObjects(); err != nil {
fmt.Fprintf(os.Stderr, "Error opening %q to clear old temp files: %s\n", lfs.LocalObjectTempDir, err)
}
}