source: Make UniqueID ... unique

Fixes #2861
This commit is contained in:
Bjørn Erik Pedersen 2016-12-31 17:46:11 +01:00
parent 02d6f5320f
commit 7d072fbbe6
2 changed files with 7 additions and 1 deletions

View file

@ -137,7 +137,7 @@ func NewFile(relpath string) *File {
} }
f.section = helpers.GuessSection(f.Dir()) f.section = helpers.GuessSection(f.Dir())
f.uniqueID = helpers.Md5String(f.LogicalName()) f.uniqueID = helpers.Md5String(f.Path())
return f return f
} }

View file

@ -14,6 +14,7 @@
package source package source
import ( import (
"path/filepath"
"strings" "strings"
"testing" "testing"
@ -26,6 +27,11 @@ func TestFileUniqueID(t *testing.T) {
assert.Equal(t, "123", f1.UniqueID()) assert.Equal(t, "123", f1.UniqueID())
assert.Equal(t, "0cc175b9c0f1b6a831c399e269772661", f2.UniqueID()) assert.Equal(t, "0cc175b9c0f1b6a831c399e269772661", f2.UniqueID())
f3 := NewFile(filepath.FromSlash("test1/index.md"))
f4 := NewFile(filepath.FromSlash("test2/index.md"))
assert.NotEqual(t, f3.UniqueID(), f4.UniqueID())
} }
func TestFileString(t *testing.T) { func TestFileString(t *testing.T) {