-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathhelpers.go
More file actions
31 lines (27 loc) · 692 Bytes
/
helpers.go
File metadata and controls
31 lines (27 loc) · 692 Bytes
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
package main
import (
"os"
"os/signal"
"path/filepath"
"syscall"
"github.com/pkg/errors"
)
func fetchFullBareRepo(root string) (string, error) {
// TODO: get host from envvar
tmpPath := filepath.Join("/", os.TempDir(), root)
_, err := os.Stat(tmpPath)
switch {
case os.IsNotExist(err) || err == nil:
if err := ipfsShell.Get(root, tmpPath); err != nil {
return "", errors.Wrapf(err, "shell.Get(%s, %s) failed: %s", root, tmpPath, err)
}
return tmpPath, nil
default:
return "", errors.Wrap(err, "os.Stat(): unhandled error")
}
}
func interrupt() error {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
return errors.Errorf("%s", <-c)
}