-
Notifications
You must be signed in to change notification settings - Fork 1
/
source_path.go
39 lines (36 loc) · 948 Bytes
/
source_path.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
package builder
import (
"fmt"
"os"
"strings"
log "github.com/sirupsen/logrus"
rsync "github.com/skiffos/skiff-core/grsync"
)
// fetchSourceRsync copies from a local path to the destination.
func (b *Builder) fetchSourceRsync(destination, source string) error {
st, err := os.Stat(source)
if err != nil {
return err
}
if !st.IsDir() {
return fmt.Errorf("Cannot sync from %s, not a directory.", source)
}
log.WithField("source", source).WithField("destination", destination).Debug("Syncing")
if !strings.HasSuffix(destination, "/") {
destination += "/"
}
if !strings.HasSuffix(source, "/") {
source += "/"
}
task := rsync.NewTask(source, destination, rsync.RsyncOptions{
// Verbose increase verbosity
Verbose: true,
// Archve is archive mode; equals -rlptgoD (no -H,-A,-X)
Archive: true,
// Recurse into directories
Recursive: true,
// Links copy symlinks as symlinks
Links: true,
})
return task.Run()
}