URI: 
       tpl: Do not write to cache when ignoring cache - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 24cb0d1f5801cc8b4dcbbf99ffb463e2e02c5dd3
   DIR parent 5d50c46482d231efa26c95e4705e720fb9bf753c
  HTML Author: Robert Basic <robertbasic.com@gmail.com>
       Date:   Sun, 10 Apr 2016 12:11:18 +0200
       
       tpl: Do not write to cache when ignoring cache
       
       Fixes #2067
       Closes #2069
       
       Diffstat:
         M commands/hugo.go                    |       2 +-
         M docs/content/extras/datadrivencont… |       5 ++---
         M docs/content/overview/usage.md      |       2 +-
         M tpl/template_resources.go           |       7 +++++--
         M tpl/template_resources_test.go      |       2 +-
       
       5 files changed, 10 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/commands/hugo.go b/commands/hugo.go
       @@ -222,7 +222,7 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
                cmd.Flags().StringVarP(&contentDir, "contentDir", "c", "", "filesystem path to content directory")
                cmd.Flags().StringVarP(&layoutDir, "layoutDir", "l", "", "filesystem path to layout directory")
                cmd.Flags().StringVarP(&cacheDir, "cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
       -        cmd.Flags().BoolVarP(&ignoreCache, "ignoreCache", "", false, "Ignores the cache directory for reading but still writes to it")
       +        cmd.Flags().BoolVarP(&ignoreCache, "ignoreCache", "", false, "Ignores the cache directory")
                cmd.Flags().StringVarP(&destination, "destination", "d", "", "filesystem path to write files to")
                cmd.Flags().StringVarP(&theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
                cmd.Flags().BoolVar(&uglyURLs, "uglyURLs", false, "if true, use /filename.html instead of /filename/")
   DIR diff --git a/docs/content/extras/datadrivencontent.md b/docs/content/extras/datadrivencontent.md
       @@ -103,9 +103,8 @@ temporary directory.
        With the command-line flag `--cacheDir`, you can specify any folder on
        your system as a caching directory.
        
       -If you don't like caching at all, you can fully disable to read from the
       -cache with the command line flag `--ignoreCache`. However, Hugo will always
       -write, on each build of the site, to the cache folder (silent backup).
       +If you don't like caching at all, you can fully disable caching with the
       +command line flag `--ignoreCache`.
        
        ### Authentication when using REST URLs
        
   DIR diff --git a/docs/content/overview/usage.md b/docs/content/overview/usage.md
       @@ -48,7 +48,7 @@ Flags:
              --disableSitemap=false: Do not build Sitemap file
              --editor="": edit new content with this editor, if provided
          -h, --help=false: help for hugo
       -      --ignoreCache=false: Ignores the cache directory for reading but still writes to it
       +      --ignoreCache=false: Ignores the cache directory
              --log=false: Enable Logging
              --logFile="": Log File path (if set, logging enabled automatically)
              --noTimes=false: Don't sync modification time of files
   DIR diff --git a/tpl/template_resources.go b/tpl/template_resources.go
       @@ -92,7 +92,10 @@ func resGetCache(id string, fs afero.Fs, ignoreCache bool) ([]byte, error) {
        }
        
        // resWriteCache writes bytes to an ID into the file cache
       -func resWriteCache(id string, c []byte, fs afero.Fs) error {
       +func resWriteCache(id string, c []byte, fs afero.Fs, ignoreCache bool) error {
       +        if ignoreCache {
       +                return nil
       +        }
                fID := getCacheFileID(id)
                f, err := fs.Create(fID)
                if err != nil {
       @@ -147,7 +150,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
                if err != nil {
                        return nil, err
                }
       -        err = resWriteCache(url, c, fs)
       +        err = resWriteCache(url, c, fs, viper.GetBool("IgnoreCache"))
                if err != nil {
                        return nil, err
                }
   DIR diff --git a/tpl/template_resources_test.go b/tpl/template_resources_test.go
       @@ -58,7 +58,7 @@ func TestScpCache(t *testing.T) {
                                t.Errorf("There is content where there should not be anything: %s", string(c))
                        }
        
       -                err = resWriteCache(test.path, test.content, fs)
       +                err = resWriteCache(test.path, test.content, fs, test.ignore)
                        if err != nil {
                                t.Errorf("Error writing cache: %s", err)
                        }