JioTV-Go / jiotv_go

Unlock the magic of JioTV across all your devices, without the need for the JioTV App. Crafted with love in Golang for a delightful blend of speed and efficiency! 🌟✨
https://jiotv_go.rabil.me/
Other
330 stars 91 forks source link

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

Closed itsyourap closed 1 week ago

itsyourap commented 1 week ago

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

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

itsyourap commented 1 week ago

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.

itsyourap commented 1 week ago

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