Skip to content

Commit

Permalink
refactor: reload default config
Browse files Browse the repository at this point in the history
  • Loading branch information
snakem982 committed Oct 23, 2024
1 parent 5904a2e commit 9e9a073
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
5 changes: 1 addition & 4 deletions backend/api/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func Filter(r chi.Router) {
return
case 2:
spider.Save2Local(proxies, "0.yaml")
reloadDefaultConfig()
render.PlainText(w, r, "true")
return
case 3:
Expand Down Expand Up @@ -215,7 +216,3 @@ func judge(array []string, key string) bool {

return false
}

func saveFile() {

}
23 changes: 13 additions & 10 deletions backend/api/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@ func crawling(w http.ResponseWriter, r *http.Request) {
return
}

bytes := cache.Get(constant.DefaultProfile)
profile := resolve.Profile{}
err := json.Unmarshal(bytes, &profile)
if err != nil {
render.NoContent(w, r)
return
}
if profile.Selected {
meta.StartCore(profile, true)
}
reloadDefaultConfig()

render.NoContent(w, r)
}
Expand Down Expand Up @@ -102,3 +93,15 @@ func deleteGetter(w http.ResponseWriter, r *http.Request) {

render.NoContent(w, r)
}

func reloadDefaultConfig() {
bytes := cache.Get(constant.DefaultProfile)
profile := resolve.Profile{}
err := json.Unmarshal(bytes, &profile)
if err != nil {
return
}
if profile.Selected {
meta.StartCore(profile, true)
}
}

0 comments on commit 9e9a073

Please sign in to comment.