When RecordCurrentDirectory fails, only log the error

If we return the error here, we don't switch repos, but the chdir
happened already, so this would be an inconsistent state (a lot of
lazygit's code assumes that the current directory is always the worktree
root). Only log the error; failing to record the current directory is
not the end of the world.

Also, it is very unlikely to happen; RecordCurrentDirectory only writes
to a small file, and if this fails, then either there is filesystem
corruption of the disk is full, and in both cases the user likely has
much bigger problems.
This commit is contained in:
Stefan Haller 2026-06-01 09:18:20 +02:00
parent 009c8975be
commit d86a49ba3f

View file

@ -171,7 +171,7 @@ func (self *ReposHelper) DispatchSwitchTo(path string, errMsg string, contextKey
} }
if err := self.recordDirectoryHelper.RecordCurrentDirectory(); err != nil { if err := self.recordDirectoryHelper.RecordCurrentDirectory(); err != nil {
return err self.c.Log.Errorf("error recording current directory: %v", err)
} }
self.c.Mutexes().RefreshingFilesMutex.Lock() self.c.Mutexes().RefreshingFilesMutex.Lock()