From 3eccd6ae009a2d067d64a6559ffa5f2417d86287 Mon Sep 17 00:00:00 2001 From: Michael Eisendle Date: Thu, 5 Feb 2015 12:31:05 +0100 Subject: [PATCH] Switch to revel.Walk, the symlink-aware filepath.Walk helper --- revel/util.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/revel/util.go b/revel/util.go index 4240565..a3328f9 100644 --- a/revel/util.go +++ b/revel/util.go @@ -66,22 +66,10 @@ func mustChmod(filename string, mode os.FileMode) { // Additionally, the trailing ".template" is stripped from the file name. // Also, dot files and dot directories are skipped. func mustCopyDir(destDir, srcDir string, data map[string]interface{}) error { - var fullSrcDir string - // Handle symlinked directories. - f, err := os.Lstat(srcDir) - if err == nil && f.Mode()&os.ModeSymlink == os.ModeSymlink { - fullSrcDir, err = os.Readlink(srcDir) - if err != nil { - panic(err) - } - } else { - fullSrcDir = srcDir - } - - return filepath.Walk(fullSrcDir, func(srcPath string, info os.FileInfo, err error) error { + return revel.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error { // Get the relative path from the source base, and the corresponding path in // the dest directory. - relSrcPath := strings.TrimLeft(srcPath[len(fullSrcDir):], string(os.PathSeparator)) + relSrcPath := strings.TrimLeft(srcPath[len(srcDir):], string(os.PathSeparator)) destPath := path.Join(destDir, relSrcPath) // Skip dot files and dot directories. @@ -124,7 +112,7 @@ func mustTarGzDir(destFilename, srcDir string) string { tarWriter := tar.NewWriter(gzipWriter) defer tarWriter.Close() - filepath.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error { + revel.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error { if info.IsDir() { return nil }