mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-10 15:52:03 -08:00
Fix launcher not using abspath
- Gets the absolute path to the Camoufox binary - Other small refactoring
This commit is contained in:
parent
e8985d692a
commit
3dc4de7a80
3 changed files with 20 additions and 19 deletions
|
|
@ -16,11 +16,11 @@ func getExecutableName() string {
|
|||
// Get the executable name based on the OS
|
||||
switch normalizeOS(runtime.GOOS) {
|
||||
case "linux":
|
||||
return "./camoufox-bin"
|
||||
return getPath("camoufox-bin")
|
||||
case "macos":
|
||||
return "./Camoufox.app"
|
||||
return getPath("Camoufox.app")
|
||||
case "windows":
|
||||
return "./camoufox.exe"
|
||||
return getPath("camoufox.exe")
|
||||
default:
|
||||
// This should never be reached due to the check in normalizeOS
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -60,6 +60,19 @@ func main() {
|
|||
runCamoufox(execName, args, addonsList)
|
||||
}
|
||||
|
||||
// Returns the absolute path relative to the launcher
|
||||
func getPath(path string) string {
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting executable path: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
execDir := filepath.Dir(execPath)
|
||||
|
||||
addonPath := filepath.Join(execDir, path)
|
||||
return addonPath
|
||||
}
|
||||
|
||||
// Parses & removes an argument from the args list
|
||||
func parseArgs(param string, defaultValue string, args *[]string, removeFromArgs bool) string {
|
||||
for i := 0; i < len(*args); i++ {
|
||||
|
|
|
|||
|
|
@ -110,27 +110,15 @@ func contains(slice []string, item string) bool {
|
|||
}
|
||||
|
||||
// Returns the absolute path to the target addon location
|
||||
func getAddonPath(addonName string) (string, error) {
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting executable path: %v\n", err)
|
||||
return "", err
|
||||
}
|
||||
execDir := filepath.Dir(execPath)
|
||||
|
||||
addonPath := filepath.Join(execDir, "addons", addonName)
|
||||
return addonPath, nil
|
||||
func getAddonPath(addonName string) string {
|
||||
return getPath(filepath.Join("addons", addonName))
|
||||
}
|
||||
|
||||
// Downloads and extracts the addons
|
||||
func maybeDownloadAddons(addons map[string]string, addonsList *[]string) {
|
||||
for addonName, url := range addons {
|
||||
// Get the addon path
|
||||
addonPath, err := getAddonPath(addonName)
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting addon path: %v\n", err)
|
||||
continue
|
||||
}
|
||||
addonPath := getAddonPath(addonName)
|
||||
|
||||
// Check if the addon is already extracted
|
||||
if _, err := os.Stat(addonPath); !os.IsNotExist(err) {
|
||||
|
|
@ -140,7 +128,7 @@ func maybeDownloadAddons(addons map[string]string, addonsList *[]string) {
|
|||
}
|
||||
|
||||
// Addon doesn't exist, create directory and download
|
||||
err = os.MkdirAll(addonPath, 0755)
|
||||
err := os.MkdirAll(addonPath, 0755)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to create directory for %s: %v\n", addonName, err)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue