1
0
mirror of https://github.com/golang/go synced 2024-11-16 19:14:43 -07:00

clean cache on fs.ErrNotExist and fs.ErrPermission

This commit is contained in:
Mateusz Poliwczak 2023-05-11 09:33:24 +02:00
parent 1ef021d167
commit cb0dac6448

View File

@ -7,6 +7,7 @@ package net
import (
"errors"
"internal/bytealg"
"io/fs"
"net/netip"
"sync"
"time"
@ -66,10 +67,7 @@ func readHosts() {
file, err := open(hp)
if err != nil {
// Return only on temporary errors (EMFILE, ENFILE), so that
// the hosts cache gets cleaned up on errors like: access, file not exist.
var temporary interface{ Temporary() bool }
if errors.As(err, &temporary) && temporary.Temporary() {
if !errors.Is(err, fs.ErrNotExist) && !errors.Is(err, fs.ErrPermission) {
return
}
}