fix: handle socket file detection on Windows

Update socket file detection logic to use os.Stat as per upstream
Go fix for https://github.com/golang/go/issues/33357. This resolves
the issue where socket files could not be properly identified on
Windows systems.
This commit is contained in:
fakecore 2024-03-08 18:16:10 +08:00
parent 7ea3d0245a
commit 4060ee60c1

View File

@ -192,15 +192,12 @@ func (m *ManagerImpl) CleanupPluginDirectory(dir string) error {
if filePath == m.checkpointFile() { if filePath == m.checkpointFile() {
continue continue
} }
// TODO: Until the bug - https://github.com/golang/go/issues/33357 is fixed, os.stat wouldn't return the stat, err := os.Stat(filePath)
// right mode(socket) on windows. Hence deleting the file, without checking whether
// its a socket, on windows.
stat, err := os.Lstat(filePath)
if err != nil { if err != nil {
klog.ErrorS(err, "Failed to stat file", "path", filePath) klog.ErrorS(err, "Failed to stat file", "path", filePath)
continue continue
} }
if stat.IsDir() { if stat.IsDir() || stat.Mode()&os.ModeSocket == 0 {
continue continue
} }
err = os.RemoveAll(filePath) err = os.RemoveAll(filePath)