Ubuntu Pastebin

Paste from Chipaca at Tue, 1 Sep 2015 09:36:17 +0000

Download as text
 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
=== modified file 'helpers/helpers.go'
--- helpers/helpers.go	2015-08-25 08:12:10 +0000
+++ helpers/helpers.go	2015-09-01 09:35:48 +0000
@@ -486,18 +486,25 @@
 	}
 
 	// then copy or update the data from srcdir to destdir
-	err = filepath.Walk(srcDirName, func(path string, info os.FileInfo, err error) error {
+	err = filepath.Walk(srcDirName, func(src string, info os.FileInfo, err error) error {
 		if err != nil {
 			return err
 		}
 
 		// relative to the root "srcDirName"
-		relPath := path[len(srcDirName):]
+		relPath := src[len(srcDirName):]
+		dst := filepath.Join(destDirName, relPath)
 		if info.IsDir() {
-			return os.MkdirAll(filepath.Join(destDirName, relPath), info.Mode())
+			if err := os.MkdirAll(dst, info.Mode()); err != nil {
+				return err
+			}
+
+			// this can panic. The alternative would be to use the "st, ok" pattern, and then if !ok... panic?
+			st := info.(*syscall.Stat_t)
+			ts := []syscall.Timespec{st.Atim, st.Mtim}
+
+			return syscall.UtimesNano(dst, ts)
 		}
-		src := path
-		dst := filepath.Join(destDirName, relPath)
 		if !FilesAreEqual(src, dst) {
 			// XXX: we should (eventually) use CopyFile here,
 			//      but we need to teach it about preserving
Download as text