Change filepaths to use filepath.Join() where possible

This commit is contained in:
2025-01-19 20:07:32 +01:00
parent 6885dfbb38
commit 9feb16a8d8
7 changed files with 26 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"time"
"github.com/google/uuid"
@@ -334,9 +335,9 @@ func (db *DB) DeleteArticle(id int64) error {
}
func WriteArticleToFile(c *Config, articleUUID uuid.UUID, content []byte) error {
articleAbsName := fmt.Sprint(c.ArticleDir, "/", articleUUID, ".md")
articlePath := filepath.Join(c.ArticleDir, fmt.Sprint(articleUUID, ".md"))
if err := os.WriteFile(articleAbsName, content, 0644); err != nil {
if err := os.WriteFile(articlePath, content, 0644); err != nil {
return fmt.Errorf("error writing article %v to file: %v", articleUUID, err)
}