Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github.com/gogf/gf/contrib/registry/file/v2@v2.7.0/file_discovery.go 的97行代码会误删其他服务的注册文件 #3462

Open
songcocl opened this issue Apr 9, 2024 · 2 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@songcocl
Copy link

songcocl commented Apr 9, 2024

github.com/gogf/gf/contrib/registry/file/v2@v2.7.0/file_discovery.go 的97行代码会误删其他服务的注册文件

@songcocl songcocl added the bug It is confirmed a bug, but don't worry, we'll handle it. label Apr 9, 2024
@songcocl songcocl changed the title github.com/gogf/gf/contrib/registry/file/v2@v2.7.0/file_discovery.go 的97行代码会勿删其他服务的注册文件 github.com/gogf/gf/contrib/registry/file/v2@v2.7.0/file_discovery.go 的97行代码会误删其他服务的注册文件 Apr 9, 2024
@houseme
Copy link
Member

houseme commented Apr 9, 2024

os.RemoveAll(path)

for _, filePath := range filePaths {
		s, e := r.getServiceByFilePath(filePath)
		if e != nil {
			return nil, e
		}
		// Check service TTL.
		var (
			updateAt    = s.GetMetadata().Get(updateAtKey).GTime()
			nowTime     = gtime.Now()
			subDuration = nowTime.Sub(updateAt)
		)
		if updateAt.IsZero() || subDuration > serviceTTL {
			g.Log().Debugf(
				ctx,
				`service "%s" is expired, update at: %s, current: %s, sub duration: %s`,
				s.GetKey(), updateAt.String(), nowTime.String(), subDuration.String(),
			)
			_ = gfile.Remove(filePath)
			continue
		}
		services = append(services, s)
	}

这里的 filePath不是一个文件路径,是一个目录路径?

@hailaz
Copy link
Member

hailaz commented May 27, 2024

请补充一下问题细节,例如复现场景描述。
https://github.com/gogf/gf/blob/v2.7.0/contrib/registry/file/file_discovery.go#L97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

3 participants