aboutsummaryrefslogtreecommitdiffstats
path: root/watcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'watcher.go')
-rw-r--r--watcher.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/watcher.go b/watcher.go
index 192b61b..d2a98e9 100644
--- a/watcher.go
+++ b/watcher.go
@@ -138,6 +138,7 @@ func syncCreate(srcPath, destPath, relPath string, manifest *Manifest, stack *Gi
}
os.MkdirAll(filepath.Dir(destPath), 0755)
+ os.Remove(destPath)
if linkTarget != "" {
if err := os.Symlink(linkTarget, destPath); err != nil {
@@ -166,10 +167,16 @@ func syncWrite(srcPath, destPath, relPath string, manifest *Manifest, dryRun, ve
return
}
+ linkTarget := ""
+ if info.Mode()&os.ModeSymlink != 0 {
+ linkTarget, _ = os.Readlink(srcPath)
+ }
+
manifest.Files[relPath] = FileMeta{
Size: info.Size(),
Mode: info.Mode(),
ModTime: info.ModTime(),
+ Symlink: linkTarget,
}
if dryRun {
@@ -177,6 +184,15 @@ func syncWrite(srcPath, destPath, relPath string, manifest *Manifest, dryRun, ve
return
}
+ os.Remove(destPath)
+
+ if linkTarget != "" {
+ if err := os.Symlink(linkTarget, destPath); err != nil {
+ log.Printf("error creating symlink %s: %v", relPath, err)
+ }
+ return
+ }
+
if err := copyFile(srcPath, destPath, info.Mode()); err != nil {
log.Printf("error copying %s: %v", relPath, err)
}