JioTV-Go/jiotv_go

bug: $HOME/.jiotv_go is created regardless of path_prefix in custom config

Closed this issue · 2 comments

Bug description

Basically, if we try to use a custom config, say at $HOME/custom/config.toml and we also define a path_prefix in the config, say at $HOME/custom/jtv. It still tries to create a folder (though empty) at $HOME/.jiotv_go.

Steps to reproduce

  • Move your $HOME/.jiotv_go folder to somewhere else, say at $HOME/custom.

  • Modify $HOME/custom/jiotv_go.toml and set path_prefix to $HOME/custom.

  • Ensure $HOME/.jiotv_go is not present.

  • Run JioTV Go with --config param set to $HOME/custom/jiotv_go.toml :-

     jiotv_go serve --config ~/config/jiotv_go.toml
    
  • You will see that though JioTV Go uses $HOME/custom as its path prefix, it also creates an empty folder at $HOME/.jiotv_go.

Relevant log output

N/A

Screenshots or videos

No response

Solution

The problem is basically in https://github.com/rabilrbl/jiotv_go/blob/f34465e7fb35ed80c73306367ee1b7e20aa1dbb7/pkg/store/store.go#L118

Somehow this method runs before the custom config is actually read and path_prefix is parsed.

Additional context

No response

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.

I put the line

log.Println("INFO: Using path prefix:", config.Cfg.PathPrefix)

at the beginning of GetPathPrefix() function and here is the output.

image

As you can see, GetPathPrefix() function was called once before actually reading the config file. Then, after reading the config file, it was called again.

The GetPathPrefix() function is called at https://github.com/rabilrbl/jiotv_go/blob/f34465e7fb35ed80c73306367ee1b7e20aa1dbb7/cmd/background.go#L15 before actually reading the config file.