fixed browsers always being created

This commit is contained in:
ACoolName 2024-05-18 12:20:56 +03:00
parent 9834ab88c8
commit f2f0e18e6c

View File

@ -684,6 +684,17 @@ func (con Connection) BrowseServer(ctx *gin.Context) {
return
}
containers, err := con.dockerClient.ContainerList(context.TODO(), container.ListOptions{Filters: filters.NewArgs(filters.Arg("label", "type=FILE_BROWSER"), filters.Arg("label", "volume_id="+serverInfo.Id))})
if err != nil {
ctx.AbortWithError(500, err)
return
}
if len(containers) > 0 {
ctx.JSON(200, "OK")
return
}
ContainerResponse, err := con.dockerClient.ContainerCreate(
context.TODO(),
&container.Config{
@ -692,9 +703,8 @@ func (con Connection) BrowseServer(ctx *gin.Context) {
Labels: browserLabels,
},
&container.HostConfig{
Mounts: []mount.Mount{{Source: serverInfo.Id, Target: "/tmp/data", Type: "volume"}},
PublishAllPorts: true,
AutoRemove: true,
Mounts: []mount.Mount{{Source: serverInfo.Id, Target: "/tmp/data", Type: "volume"}},
AutoRemove: true,
},
&network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{"test": {