Repository: getnikola/nikola

Issue:
Windows task conflict
As reported by @berezovskyi on IRC:

```
ERROR: 'output\posts\math-test-new\index.html' is a target for render_indexes:output\posts\math-test-new\index.html and render_pages:output\posts\math-test-new\index.html
```

Happens if more than one post exists; Windows and v7.7.0 only.  Probably needs some `git bisect` first.

Repo: https://github.com/berezovskyi/nikola-troubleshoot



Discussion:
I just finished doing `bisect` and here is what I found:

```
> git bisect good
b6f2eee7801bd9c42b2386d3067ee99098587170 is the first bad commit
commit b6f2eee7801bd9c42b2386d3067ee99098587170
Author: Daniel Aleksandersen <code@daniel.priv.no>
Date:   Thu Aug 27 15:09:38 2015 +0200

    Adds THEME_COLORS, POSTS_CATEGORIES, POSTS_CATEGORY_*, and HUSL color functions

    Issue #1980

:100644 100644 ddae855b65ce56a0f9477b4c18345c0bcfd7c775 80e01abb9a3f14a5b590a122b89fe3cf93af482a M      CHANGES.txt
:040000 040000 da7f376c29744e6dc47235d6207589818559ac84 f213f334531d3f168a552256fd7b591880cf4f7c M  nikola
:100644 100644 5d2c7d2a4cad4e81eb8b97126fef20c12d171c82 0b5fe4e934e55f446fdbebe3a6e43e6478bc0810 M  requirements.txt
```

Commit b6f2eee7801bd9c42b2386d3067ee99098587170 

That commit is really large: https://github.com/getnikola/nikola/commit/b6f2eee7801bd9c42b2386d3067ee99098587170

I’m afraid we will have to do some testing and debugging ourselves, because something in here introduces a conflicts and believes that `\posts\bar\index.html` makes for a great `\posts\bar\` section, which it shouldn’t.  (Why this didn’t get fixed by disabling POST_SECTIONS amazes me.)

I guess some debugging with sections on Windows is needed. Anyone else up for it or should I try myself?

Random guess: how about trying `'\'` for `'/'` in this line? https://github.com/getnikola/nikola/commit/b6f2eee7801bd9c42b2386d3067ee99098587170#diff-02eee555d5000aa9b2fe4259d59db08aR774

(I don't have Windows, so I can't try...)

That might be a good idea.  @berezovskyi, mind testing that quickly?  (or even replacing with `os.sep`)

@felixfontein bingo! The following fixes the build:

```
> git diff
diff --git a/nikola/post.py b/nikola/post.py
index 49c629c..672baa6 100644
--- a/nikola/post.py
+++ b/nikola/post.py
@@ -771,7 +771,7 @@ class Post(object):
     def category_slug(self, lang=None):
         if not self.config['POSTS_CATEGORY_FROM_META']:
             dest = self.destination_path(lang)
-            if dest[-(1 + len(self.index_file)):] == '/' + self.index_file:
+            if dest[-(1 + len(self.index_file)):] == os.sep + self.index_file:
                 dest = dest[:-(1 + len(self.index_file))]
             dirname = os.path.dirname(dest)
             slug = dirname
```

I think it might need a better review but I'm pretty confident it should work on Linux as well.

Cool :)
On Linux, `os.sep` equals `'/'`, so it should definitely work.

Shall I try to make a pull request?

Sure!

Please do.


Resolving patch:
diff --git a/nikola/post.py b/nikola/post.py
--- a/nikola/post.py
+++ b/nikola/post.py
@@ -769,7 +769,7 @@ def section_slug(self, lang=None):
 
         if not self.config['POSTS_SECTION_FROM_META']:
             dest = self.destination_path(lang)
-            if dest[-(1 + len(self.index_file)):] == '/' + self.index_file:
+            if dest[-(1 + len(self.index_file)):] == os.sep + self.index_file:
                 dest = dest[:-(1 + len(self.index_file))]
             dirname = os.path.dirname(dest)
             slug = dest.split(os.sep)


Test patch: