sync: search theme's label in a title.txt file, fallback on dirname

This commit is contained in:
nemunaire 2019-09-06 20:12:01 +02:00
parent 6f7bd3b785
commit 4e01377a29
2 changed files with 14 additions and 2 deletions

View file

@ -57,7 +57,9 @@ func BuildTheme(i Importer, tdir string) (th *fic.Theme, errs []string) {
th.Path = tdir
// Extract theme's label
if f := strings.Index(tdir, "-"); f >= 0 {
if tname, err := getFileContent(i, path.Join(tdir, "title.txt")); err == nil {
th.Name = fixnbsp(tname)
} else if f := strings.Index(tdir, "-"); f >= 0 {
th.Name = fixnbsp(tdir[f+1:])
} else {
th.Name = fixnbsp(tdir)
@ -130,7 +132,7 @@ func SyncThemes(i Importer) []string {
}
var theme fic.Theme
if theme, err = fic.GetThemeByName(btheme.Name); err != nil {
if theme, err = fic.GetThemeByPath(btheme.Path); err != nil {
if _, err := fic.CreateTheme(*btheme); err != nil {
errs = append(errs, fmt.Sprintf("%q: an error occurs during add: %s", tdir, err))
continue