Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browsers/chrome/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (*Chrome) ListFlavours() []browsers.BrowserDef {
// detect local flavours
for _, v := range browsers.Defined(browsers.ChromeBased) {
if v.Detect() {
result = append(result, v)
result = append(result, *v)
}
}

Expand Down
21 changes: 10 additions & 11 deletions browsers/firefox/firefox.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package firefox

import (
"fmt"
"path"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -677,22 +676,22 @@ func (f *Firefox) addFolderNode(folder MozFolder) (bool, *tree.Node) {

// Copies places.sqlite to a tmp dir to read a VFS lock sqlite db
func (f *Firefox) initPlacesCopy() (mozilla.PlaceCopyJob, error) {
// create a new copy job
pc := mozilla.NewPlaceCopyJob()

err := utils.CopyFilesToTmpFolder(path.Join(f.BkDir, f.BkFile+"*"), pc.Path())
// Construire le chemin source correctement
sourcePath := filepath.Join(f.BkDir, f.BkFile)

// Copier seulement le fichier principal
err := utils.CopyFileToTmp(sourcePath, pc.Path(), f.BkFile)
if err != nil {
return pc, fmt.Errorf("could not copy places.sqlite to tmp folder: %w", err)
return pc, fmt.Errorf("could not copy places.sqlite: %w", err)
}

opts := FFConfig.PlacesDSN

f.places, err = database.NewDB("places",
// using the copied places file instead of the original to avoid
// sqlite vfs lock errors
path.Join(pc.Path(), f.BkFile),
database.DBTypeFileDSN, opts).Init()
// Construire le chemin destination correctement
destPath := filepath.Join(pc.Path(), f.BkFile)

opts := FFConfig.PlacesDSN
f.places, err = database.NewDB("places", destPath, database.DBTypeFileDSN, opts).Init()
if err != nil {
return pc, err
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/gosuki/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func runBrowserModule(m *manager.Manager,
log.Error(err)
return err
}

if _, err := pfl.AbsolutePath(); err != nil {
log.Warnf("profile path is invalid: %s", err)
return &modules.ErrModDisabled{Err: err}
}

if err := bpm.UseProfile(pfl, flav); err != nil {
log.Warnf("unable to load profile <%s.%s>: %s", mod.ID, pfl.Name, err)
return &modules.ErrModDisabled{Err: err}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gosuki/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// along with gosuki. If not, see <http://www.gnu.org/licenses/>.
//

//go:build (systray && darwin) || !systray
//go:build (systray && darwin) || (systray && windows) || !systray

package main

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ require (
)

require (
fyne.io/systray v1.11.0 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
Expand All @@ -48,7 +49,8 @@ require (
github.com/ebitengine/purego v0.8.4 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/go-tpm v0.9.5 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
fyne.io/systray v1.11.0 h1:D9HISlxSkx+jHSniMBR6fCFOUjk1x/OOOJLa9lJYAKg=
fyne.io/systray v1.11.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557 h1:l6surSnJ3RP4qA1qmKJ+hQn3UjytosdoG27WGjrDlVs=
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557/go.mod h1:sTrmvD/TxuypdOERsDOS7SndZg0rzzcCi1b6wQMXUYM=
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
Expand Down Expand Up @@ -76,6 +78,10 @@ github.com/gobuffalo/flect v0.3.0 h1:erfPWM+K1rFNIQeRPdeEXxo8yFr/PO17lhRnS8FUrtk
github.com/gobuffalo/flect v0.3.0/go.mod h1:5pf3aGnsvqvCj50AVni7mJJF8ICxGZ8HomberC3pXLE=
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
Expand Down
Binary file added gosuki.exe
Binary file not shown.
56 changes: 13 additions & 43 deletions internal/database/locks.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
// Copyright (c) 2023-2025 Chakib Ben Ziane <[email protected]> and [`GoSuki` contributors]
// (https://github.com/blob42/gosuki/graphs/contributors).
//
// All rights reserved.
//
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This file is part of GoSuki.
//
// GoSuki is free software: you can redistribute it and/or modify it under the terms of
// the GNU Affero General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// GoSuki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with
// gosuki. If not, see <http://www.gnu.org/licenses/>.

package database

import (
"os"

"golang.org/x/sys/unix"
"github.com/gofrs/flock"
)

type LockChecker interface {
Expand All @@ -35,28 +13,20 @@ type VFSLockChecker struct {
}

func (checker *VFSLockChecker) Locked() (bool, error) {

f, err := os.Open(checker.path)
fileLock := flock.New(checker.path)

// Essayer de prendre le lock avec un timeout immédiat
locked, err := fileLock.TryLock()
if err != nil {
return false, err
}

// Get the the lock mode
var lock unix.Flock_t
// See man (fcntl)
unix.FcntlFlock(f.Fd(), unix.F_GETLK, &lock)

// Check if lock is F_RDLCK (non-exclusive) or F_WRLCK (exclusive)
if lock.Type == unix.F_RDLCK {
//log.Debug("Lock is F_RDLCK")

if locked {
// On a réussi à prendre le lock, donc il n'était pas locked
fileLock.Unlock()
return false, nil
}

if lock.Type == unix.F_WRLCK {
//log.Debug("Lock is F_WRLCK (locked !)")
return true, nil
}

return false, nil

}

// On n'a pas réussi à prendre le lock, donc il est locked par quelqu'un d'autre
return true, nil
}
46 changes: 46 additions & 0 deletions internal/gui/systray_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//go:build windows && systray
// +build windows,systray

package gui

import (
"os"
"os/signal"
"syscall"

"github.com/energye/systray"
)

// WindowsRunSystray démarre la systray pour Windows
func WindowsRunSystray(manager interface{}) {
// Gérer les signaux système
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)

go func() {
<-c
systray.Quit()
}()

// Démarrer la systray
systray.Run(onReady, onExit)
}

func onReady() {
// Titre et tooltip de base
systray.SetTitle("Gosuki")
systray.SetTooltip("Gosuki - Browser Bookmark Manager")

// Menu basique
mQuit := systray.AddMenuItem("Quit", "Quit Gosuki")

// Gestion du clic Quit
go func() {
<-mQuit.ClickedCh
systray.Quit()
}()
}

func onExit() {
// Nettoyage si nécessaire
}
12 changes: 12 additions & 0 deletions internal/utils/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ func CopyFilesToTmpFolder(srcglob string, dst string) error {

}

func CopyFileToTmp(source, tmpDir, filename string) error {
srcFile := filepath.Clean(source)
dstFile := filepath.Join(tmpDir, filename)

input, err := os.ReadFile(srcFile)
if err != nil {
return err
}

return os.WriteFile(dstFile, input, 0644)
}

// TEST:
func CleanFiles() {
log.Debugf("cleaning files <%s>", TMPDIR)
Expand Down
9 changes: 8 additions & 1 deletion internal/utils/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,17 @@ func ExpandPath(paths ...string) (string, error) {
if len(paths) == 0 {
return "", fmt.Errorf("no path provided")
}

path := os.ExpandEnv(filepath.Join(paths...))

// Vérifier si le chemin est vide après expansion
if path == "" {
return "", fmt.Errorf("expanded path is empty")
}

if homedir, err = os.UserHomeDir(); err != nil {
return "", err
}
path := os.ExpandEnv(filepath.Join(paths...))

if path[0] == '~' {
path = filepath.Join(homedir, path[1:])
Expand Down
Loading