mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-16 12:01:00 +01:00
fix #4, use filepath.Join to create portable path's
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -176,7 +177,7 @@ func ScrapeImages(dir string, ad *Ad) error {
|
||||
failure := make(chan string)
|
||||
|
||||
for _, imguri := range ad.Images {
|
||||
file := fmt.Sprintf("%s/%d.jpg", dir, img)
|
||||
file := filepath.Join(dir, ad.Slug, fmt.Sprintf("%d.jpg", img))
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
err := Getimage(imguri, file)
|
||||
|
||||
5
store.go
5
store.go
@@ -21,20 +21,21 @@ import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
tpl "text/template"
|
||||
)
|
||||
|
||||
func WriteAd(dir string, ad *Ad, template string) error {
|
||||
// prepare output dir
|
||||
dir = dir + "/" + ad.Slug
|
||||
dir = filepath.Join(dir, ad.Slug)
|
||||
err := Mkdir(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// write ad file
|
||||
listingfile := strings.Join([]string{dir, "Adlisting.txt"}, "/")
|
||||
listingfile := filepath.Join(dir, "Adlisting.txt")
|
||||
f, err := os.Create(listingfile)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user