Fix filepath separators for Windows build
This commit is contained in:
parent
3b81551681
commit
ca04c0625a
@ -4,7 +4,6 @@ import (
|
|||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
sql "github.com/jmoiron/sqlx"
|
sql "github.com/jmoiron/sqlx"
|
||||||
@ -41,13 +40,13 @@ func NewProfile(target_dir string) (Profile, error) {
|
|||||||
return Profile{}, fmt.Errorf("Could not create target %q:\n %w", target_dir, ErrTargetAlreadyExists)
|
return Profile{}, fmt.Errorf("Could not create target %q:\n %w", target_dir, ErrTargetAlreadyExists)
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_file := path.Join(target_dir, "settings.yaml")
|
settings_file := filepath.Join(target_dir, "settings.yaml")
|
||||||
sqlite_file := path.Join(target_dir, "twitter.db")
|
sqlite_file := filepath.Join(target_dir, "twitter.db")
|
||||||
profile_images_dir := path.Join(target_dir, "profile_images")
|
profile_images_dir := filepath.Join(target_dir, "profile_images")
|
||||||
link_thumbnails_dir := path.Join(target_dir, "link_preview_images")
|
link_thumbnails_dir := filepath.Join(target_dir, "link_preview_images")
|
||||||
images_dir := path.Join(target_dir, "images")
|
images_dir := filepath.Join(target_dir, "images")
|
||||||
videos_dir := path.Join(target_dir, "videos")
|
videos_dir := filepath.Join(target_dir, "videos")
|
||||||
video_thumbnails_dir := path.Join(target_dir, "video_thumbnails")
|
video_thumbnails_dir := filepath.Join(target_dir, "video_thumbnails")
|
||||||
|
|
||||||
// Create the directory
|
// Create the directory
|
||||||
fmt.Printf("Creating new profile: %s\n", target_dir)
|
fmt.Printf("Creating new profile: %s\n", target_dir)
|
||||||
@ -121,8 +120,8 @@ func NewProfile(target_dir string) (Profile, error) {
|
|||||||
// returns:
|
// returns:
|
||||||
// - the loaded Profile
|
// - the loaded Profile
|
||||||
func LoadProfile(profile_dir string) (Profile, error) {
|
func LoadProfile(profile_dir string) (Profile, error) {
|
||||||
settings_file := path.Join(profile_dir, "settings.yaml")
|
settings_file := filepath.Join(profile_dir, "settings.yaml")
|
||||||
sqlite_file := path.Join(profile_dir, "twitter.db")
|
sqlite_file := filepath.Join(profile_dir, "twitter.db")
|
||||||
|
|
||||||
for _, file := range []string{
|
for _, file := range []string{
|
||||||
settings_file,
|
settings_file,
|
||||||
@ -157,13 +156,13 @@ func LoadProfile(profile_dir string) (Profile, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p Profile) ListSessions() []scraper.UserHandle {
|
func (p Profile) ListSessions() []scraper.UserHandle {
|
||||||
result, err := filepath.Glob(path.Join(p.ProfileDir, "*.session"))
|
result, err := filepath.Glob(filepath.Join(p.ProfileDir, "*.session"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ret := []scraper.UserHandle{}
|
ret := []scraper.UserHandle{}
|
||||||
for _, filename := range result {
|
for _, filename := range result {
|
||||||
ret = append(ret, scraper.UserHandle(path.Base(filename[:len(filename)-len(".session")])))
|
ret = append(ret, scraper.UserHandle(filepath.Base(filename[:len(filename)-len(".session")])))
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user