Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Scrapers dir can't be a symlink #706

Closed
woodgen opened this issue Aug 5, 2020 · 3 comments · Fixed by #938
Closed

[Bug Report] Scrapers dir can't be a symlink #706

woodgen opened this issue Aug 5, 2020 · 3 comments · Fixed by #938
Labels
good first issue Good for newcomers Hacktoberfest help wanted Extra attention is needed

Comments

@woodgen
Copy link
Contributor

woodgen commented Aug 5, 2020

Describe the bug

stash is unable to load scrapers if the scrapers dir is a symlink. There is no error in the log. Scrapers just don't load.

$ ls -al .stash/scrapers
lrwxrwxrwx 1 user user 59 Aug  1 13:32 .stash/scrapers -> /home/user/code/CommunityScrapers/scrapers/

ls .stash/scrapers returns correclty the target scrapers dir content, so the symlink works.

It would be great for this to work, so i.e. the scrapers folder from the CommunityScrapers git repo could be symlinked and used with version control.

To Reproduce
Steps to reproduce the behavior:

  1. replace ~/.stash/scrapers with a symlink
  2. Reload scrapers.
  3. No profit.

Expected behavior
stash should find the scrapers.

Stash Version: (from Settings -> About):
git master b465c36

Desktop (please complete the following information):

  • OS: Arch Linux
  • Browser Chromium 84.0.4147.105
@woodgen woodgen added the help wanted Extra attention is needed label Aug 5, 2020
@peolic
Copy link
Contributor

peolic commented Aug 5, 2020

as a workaround I believe you can directly set the scrapers path on config.yml:

scrapers_path: /home/user/code/CommunityScrapers/scrapers/

@bnkai
Copy link
Collaborator

bnkai commented Aug 5, 2020

For the loadscrapers function filepath.Walk is used which doesnt follow symlinks by design ( to make sure no loop is created )
If we switch to facebook symwalk instead the issue is resolved, the user just has to make sure though that he doesn't create a loop using symlinks.
All that needs to be changed is

diff --git a/pkg/scraper/scrapers.go b/pkg/scraper/scrapers.go
index 864c09a..1aa94c5 100644
--- a/pkg/scraper/scrapers.go
+++ b/pkg/scraper/scrapers.go
@@ -9,6 +9,8 @@ import (
 
        "github.com/stashapp/stash/pkg/logger"
        "github.com/stashapp/stash/pkg/models"
+
+       "github.com/facebookgo/symwalk"
 )
 
 // GlobalConfig contains the global scraper options.
@@ -58,7 +60,7 @@ func loadScrapers(path string) ([]config, error) {
 
        logger.Debugf("Reading scraper configs from %s", path)
        scraperFiles := []string{}
-       err := filepath.Walk(path, func(fp string, f os.FileInfo, err error) error {
+       err := symwalk.Walk(path, func(fp string, f os.FileInfo, err error) error {
                if filepath.Ext(fp) == ".yml" {
                        scraperFiles = append(scraperFiles, fp)
                }

and a go mod vendor

@woodgen
Copy link
Contributor Author

woodgen commented Aug 5, 2020

@bnkai Thanks for the patch. Tested it and it works like a charm.
I would welcome this patch to land.

@peolic The config approach is a valid solution as well. I will use it if @bnkai decides to not push this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants