forked from jason/cpolis
Change filepaths to use filepath.Join() where possible
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user