Skip to content

Commit

Permalink
chore: avoid hardcode cache directories
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Jun 15, 2022
1 parent 5820d83 commit e42b813
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func getInternalResType(url string) int {
}

const LABEL_NO_VALID_VALUE = "N/A"
const CACHE_META_DIR = "./.aptcache/header/v1"

func renderInternalUrls(url string, rw *http.ResponseWriter) {
types := getInternalResType(url)
Expand All @@ -56,8 +57,8 @@ func renderInternalUrls(url string, rw *http.ResponseWriter) {
}

filesNumberLabel := LABEL_NO_VALID_VALUE
if _, err := os.Stat("./.aptcache/header/v1"); !os.IsNotExist(err) {
files, err := ioutil.ReadDir("./.aptcache/header/v1")
if _, err := os.Stat(CACHE_META_DIR); !os.IsNotExist(err) {
files, err := ioutil.ReadDir(CACHE_META_DIR)
if err == nil {
filesNumberLabel = strconv.Itoa(len(files))
}
Expand Down

0 comments on commit e42b813

Please sign in to comment.