File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 4
4
import json
5
5
import logging
6
6
import struct
7
+ from dateutil import parser
8
+ from datetime import datetime
7
9
from os import getgid , getuid
8
10
from pathlib import Path
9
11
from re import match
@@ -434,6 +436,19 @@ def parse_kernel_version(url: str) -> str:
434
436
return ""
435
437
436
438
439
+ def is_fully_compiled_version (version : str ) -> bool :
440
+ """Check that a given version is at least 48h old"""
441
+ response = client_get (
442
+ settings .upstream_url + "/releases/" + version + "/.targets.json"
443
+ )
444
+
445
+ if response .extensions ["from_cache" ]:
446
+ last_modified = int (parser .parse (response .headers ["Last-Modified" ]).timestamp ())
447
+ if int (datetime .now ().timestamp ()) - last_modified < 172800 :
448
+ return False
449
+ return True
450
+
451
+
437
452
def reload_versions (app : FastAPI ) -> bool :
438
453
response = client_get (settings .upstream_url + "/.versions.json" )
439
454
@@ -451,6 +466,12 @@ def reload_versions(app: FastAPI) -> bool:
451
466
if response .json ()["upcoming_version" ]:
452
467
app .versions .append (response .json ()["upcoming_version" ])
453
468
469
+ # Avoid offering versions that are not yet fully compiled
470
+ for label in ["stable_version" , "oldstable_version" , "upcoming_version" ]:
471
+ version = response .json ()[label ]
472
+ if version and not is_fully_compiled_version (version ):
473
+ app .versions .remove (version )
474
+
454
475
for branch in settings .branches .keys ():
455
476
if branch != "SNAPSHOT" :
456
477
app .versions .append (f"{ branch } -SNAPSHOT" )
Original file line number Diff line number Diff line change @@ -7,14 +7,18 @@ cache_dir ufs /var/spool/squid 50000 16 256
7
7
# Set memory cache size
8
8
cache_mem 5 GB
9
9
10
- # Prevent caching for one year uncompleted kernel modules during compilation (should be updated once a new release is published)
11
- refresh_pattern ^http://downloads.openwrt.org/releases/.*(23.05.[6-99]|24.10.[1-99]|25.*|SNAPSHOT)/targets/.* 0 100% 0 refresh-ims
10
+ # Consider replacing 'downloads.openwrt.org' with '.*openwrt.*' to include multiple mirrors
11
+ # Always revalidate imagebuilders and sha256sums with the origin server
12
+ refresh_pattern ^http://downloads.openwrt.org/releases/.*/targets/.*(imagebuilder|sha256sums).* 0 100% 0 refresh-ims
12
13
13
- # Kernel modules for releases are compiled once, never expires: cache for a year
14
- refresh_pattern ^http://downloads.openwrt.org/releases/.*/targets/ .* 525600 0% 525600 override-expire
14
+ # Always revalidate the content of snapshots with the origin server
15
+ refresh_pattern -i ^http://downloads.openwrt.org/.*snapshot .* 0 100% 0 refresh-ims
15
16
16
- # Prevent revalidate cached content with the origin server for 30min (should exist a fallback to no_proxy)
17
- refresh_pattern ^http://downloads.openwrt.org/.*[^imagebuilder].* 30 0% 30 override-expire
17
+ # Kernel modules for releases are compiled once, never expires: cache for one year
18
+ refresh_pattern ^http://downloads.openwrt.org/releases/.*/targets/.* 525600 100% 525600 override-expire
19
+
20
+ # Consider all the remaning packages as fresh for 30min (should exist a fallback to no_proxy)
21
+ refresh_pattern ^http://downloads.openwrt.org/.* 30 100% 30 override-expire
18
22
19
23
# Always revalidate cached content with the origin server
20
24
refresh_pattern . 0 100% 0 refresh-ims
You can’t perform that action at this time.
0 commit comments