Fix bug creating cache dir
This commit is contained in:
@@ -3,6 +3,7 @@ package internal
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
@@ -52,7 +53,14 @@ func Scrape(conf *Config, url string) (*Entry, error) {
|
||||
HTMLContent: article.Content,
|
||||
}
|
||||
|
||||
fn := filepath.Join(conf.Data, cacheDir, fmt.Sprintf("%s.json", entry.Hash()))
|
||||
p := filepath.Join(conf.Data, cacheDir)
|
||||
if err := os.MkdirAll(p, 0755); err != nil {
|
||||
log.WithError(err).Error("error creating cache directory")
|
||||
return nil, fmt.Errorf("error creating cache directory: %w", err)
|
||||
}
|
||||
|
||||
fn := filepath.Join(p, fmt.Sprintf("%s.json", entry.Hash()))
|
||||
|
||||
data, err := entry.Bytes()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("error serializing entry")
|
||||
|
||||
Reference in New Issue
Block a user