Jelajahi Sumber

Fix: osl-registry cached download/ETag state mismatch

After upgrading an existing client to the new streaming
OSL download code, it was possible for the last downloaded
ETag to be the latest version, but for no cached download
file to be on disk.
Rod Hynes 8 tahun lalu
induk
melakukan
314ccffcca
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 7 0
      psiphon/remoteServerList.go

+ 7 - 0
psiphon/remoteServerList.go

@@ -134,6 +134,13 @@ func FetchObfuscatedServerLists(
 	downloadURL := osl.GetOSLRegistryURL(rootURL)
 	downloadURL := osl.GetOSLRegistryURL(rootURL)
 	canonicalURL := osl.GetOSLRegistryURL(canonicalRootURL)
 	canonicalURL := osl.GetOSLRegistryURL(canonicalRootURL)
 
 
+	// If the cached registry is not present, we need to download or resume downloading
+	// the registry, so clear the ETag to ensure that always happens.
+	_, err := os.Stat(cachedFilename)
+	if os.IsNotExist(err) {
+		SetUrlETag(canonicalURL, "")
+	}
+
 	// failed is set if any operation fails and should trigger a retry. When the OSL registry
 	// failed is set if any operation fails and should trigger a retry. When the OSL registry
 	// fails to download, any cached registry is used instead; when any single OSL fails
 	// fails to download, any cached registry is used instead; when any single OSL fails
 	// to download, the overall operation proceeds. So this flag records whether to report
 	// to download, the overall operation proceeds. So this flag records whether to report