mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-11 17:26:57 +02:00
v0.6.14 : creer le dossier bin a la premiere installation
Sur une machine vierge, le premier lancement du fichier telecharge echouait sur « open C:\ProgramData\jean\bin\jean.exe: The system cannot find the path specified » : appFirstRun creait le dossier de donnees mais pas son sous-dossier bin, cree jusqu'ici par le seul `jean install`. AJEAN demarrait alors depuis le fichier telecharge, sans installation ni raccourcis. MkdirAll deplace dans installSelf, donc valable quel que soit l'appelant. Reproduit puis verifie sur banc d'essai Windows (parcours complet depuis un dossier de donnees inexistant), + test unitaire.
This commit is contained in:
1 parent
0e94f1e9e2
commit
26ce8a9a14
7 files changed
+40
-13
No files matched your search
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const Version = "0.6.13"
|
||||
const Version = "0.6.14"
|
||||
|
||||
// Main est le vrai main() du binaire (cmd/jean ne fait que l'appeler).
|
||||
func Main() {
|
||||
|
||||
@@ -26,6 +26,21 @@ func TestBinaryVersionReadsResource(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Sur une machine vierge, le dossier bin n'existe pas encore : installSelf doit
|
||||
// le créer. Sans ça, le premier lancement échouait sur « open
|
||||
// C:\ProgramData\jean\bin\jean.exe: The system cannot find the path specified »
|
||||
// et AJEAN ne s'installait jamais.
|
||||
func TestInstallSelfCreatesBinDir(t *testing.T) {
|
||||
binDir := filepath.Join(t.TempDir(), "jean", "bin") // deux niveaux absents
|
||||
dst, err := installSelf(binDir)
|
||||
if err != nil {
|
||||
t.Fatalf("installSelf sur un dossier absent : %v", err)
|
||||
}
|
||||
if _, err := os.Stat(dst); err != nil {
|
||||
t.Fatalf("binaire non écrit : %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// replaceInstalled doit écraser le binaire en place, y compris quand le fichier
|
||||
// cible existe déjà, et laisser l'ancien de côté sans le confondre avec la cible.
|
||||
func TestReplaceInstalled(t *testing.T) {
|
||||
|
||||
@@ -100,6 +100,12 @@ func cmdInstall(args []string) error {
|
||||
// installSelf copies the currently running executable into binDir as jean.exe
|
||||
// and returns the destination path. If the running exe already lives there
|
||||
// (re-install), it's a no-op.
|
||||
//
|
||||
// binDir est créé ici, et pas seulement par l'appelant : sur une machine vierge,
|
||||
// le premier lancement passait par appFirstRun, qui ne créait que le dossier de
|
||||
// données et pas son sous-dossier bin. L'utilisateur recevait alors « open
|
||||
// C:\ProgramData\jean\bin\jean.exe: The system cannot find the path specified »
|
||||
// et AJEAN démarrait depuis le fichier téléchargé, sans jamais s'installer.
|
||||
func installSelf(binDir string) (string, error) {
|
||||
src, err := os.Executable()
|
||||
if err != nil {
|
||||
@@ -110,6 +116,9 @@ func installSelf(binDir string) (string, error) {
|
||||
if strings.EqualFold(src, dst) {
|
||||
return dst, nil
|
||||
}
|
||||
if err := os.MkdirAll(binDir, 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
in, err := os.Open(src)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in new issue
Block a user