Repository: getnikola/nikola

Issue:
render fails if the theme has a code.css  
The `conf.py` says: 

```
# Color scheme to be used for code blocks. If your theme provides
# "assets/css/code.css" this is ignored.
```

I've [provided one](https://github.com/mgaitan/my-nikola-theme/commit/f0140d0d67771d7ee9f46df2c78548c0e757f65e) but then I can't render my site

```
(blog)tin@morochita:~/lab/blog$ nikola build
Scanning posts.....done!
ERROR: Two different tasks can't have a common target.'output/assets/css/code.css' is a target for copy_files:output/assets/css/code.css and copy_assets:output/assets/css/code.css.
(blog)tin@morochita:~/lab/blog$ 
```



Discussion:
The check must have been broken…

In the meantime, as a fix, you can nuke [the generation part](https://github.com/getnikola/nikola/blob/master/nikola/plugins/task/copy_assets.py#L72) from our sources (just delete line 72 and everything after it).


Resolving patch:
diff --git a/nikola/plugins/task/copy_assets.py b/nikola/plugins/task/copy_assets.py
--- a/nikola/plugins/task/copy_assets.py
+++ b/nikola/plugins/task/copy_assets.py
@@ -45,15 +45,21 @@ def gen_tasks(self):
 
         kw = {
             "themes": self.site.THEMES,
+            "files_folders": self.site.config['FILES_FOLDERS'],
             "output_folder": self.site.config['OUTPUT_FOLDER'],
             "filters": self.site.config['FILTERS'],
             "code_color_scheme": self.site.config['CODE_COLOR_SCHEME'],
             "code.css_selectors": 'pre.code',
+            "code.css_head": '/* code.css file generated by Nikola */\n',
             "code.css_close": "\ntable.codetable { width: 100%;} td.linenos {text-align: right; width: 4em;}\n",
         }
-        has_code_css = False
         tasks = {}
         code_css_path = os.path.join(kw['output_folder'], 'assets', 'css', 'code.css')
+        code_css_input = utils.get_asset_path('assets/css/code.css',
+                                              themes=kw['themes'],
+                                              files_folders=kw['files_folders'])
+
+        kw["code.css_input"] = code_css_input
 
         yield self.group_task()
 
@@ -63,27 +69,35 @@ def gen_tasks(self):
             for task in utils.copy_tree(src, dst):
                 if task['name'] in tasks:
                     continue
-                has_code_css = task['targets'][0] == code_css_path
                 tasks[task['name']] = task
                 task['uptodate'] = [utils.config_changed(kw)]
                 task['basename'] = self.name
+                if code_css_input:
+                    task['file_dep'] = [code_css_input]
                 yield utils.apply_filters(task, kw['filters'])
 
-        if not has_code_css:  # Generate it
-
+        # Check whether or not there is a code.css file around.
+        if not code_css_input:
             def create_code_css():
                 from pygments.formatters import get_formatter_by_name
                 formatter = get_formatter_by_name('html', style=kw["code_color_scheme"])
                 utils.makedirs(os.path.dirname(code_css_path))
                 with codecs.open(code_css_path, 'wb+', 'utf8') as outf:
+                    outf.write(kw["code.css_head"])
                     outf.write(formatter.get_style_defs(kw["code.css_selectors"]))
                     outf.write(kw["code.css_close"])
 
+            if os.path.exists(code_css_path):
+                with codecs.open(code_css_path, 'r', 'utf-8') as fh:
+                    testcontents = fh.read(len(kw["code.css_head"])) == kw["code.css_head"]
+            else:
+                testcontents = False
+
             task = {
                 'basename': self.name,
                 'name': code_css_path,
                 'targets': [code_css_path],
-                'uptodate': [utils.config_changed(kw)],
+                'uptodate': [utils.config_changed(kw), testcontents],
                 'actions': [(create_code_css, [])],
                 'clean': True,
             }


Test patch: