Skip to content

fix(sync): remote Delete/Rename events not propagated locally — leading slash in evt.Path #155

Description

@CCoupel

Symptôme

Suppression ou renommage d'un fichier côté remote → le fichier local n'est pas supprimé/renommé.

Root cause

handleRemoteEvent :

localPath := filepath.Join(e.localDir, evt.Path)

Les backends Watch() peuvent retourner des chemins avec un slash initial (ex : /file.txt). Sur Windows :
filepath.Join("C:\\GhostDrive\\Backend", "/file.txt") = C:\file.txt (le second composant absolu écrase le premier → chemin hors sync root). os.Remove("C:\file.txt") échoue silencieusement (fichier introuvable à cet endroit) → fichier local non supprimé.

Fix

internal/sync/engine.go handleRemoteEvent :

relPath := strings.TrimLeft(filepath.FromSlash(evt.Path), "/\\\\")
localPath := filepath.Join(e.localDir, relPath)
// Idem pour evt.OldPath dans FileEventRenamed
oldRelPath := strings.TrimLeft(filepath.FromSlash(evt.OldPath), "/\\\\")

Ajout de logger.Error/Info pour tracer les outcomes de os.Remove/os.Rename.

Tests

TestEngine_HandleRemoteEvent_LeadingSlash_Delete, TestEngine_HandleRemoteEvent_LeadingSlash_Rename

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendCode Go / moteur de synchronisationbugSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions