@@ -52,10 +52,15 @@ pub struct Config {
52
52
rustdoc : LazyCell < PathBuf > ,
53
53
/// Whether we are printing extra verbose messages
54
54
extra_verbose : bool ,
55
- /// `frozen` is set if we shouldn't access the network
55
+ /// `frozen` is the same as `locked`, but additionally will not access the
56
+ /// network to determine if the lock file is out-of-date.
56
57
frozen : bool ,
57
- /// `locked` is set if we should not update lock files
58
+ /// `locked` is set if we should not update lock files. If the lock file
59
+ /// is missing, or needs to be updated, an error is produced.
58
60
locked : bool ,
61
+ /// `offline` is set if we should never access the network, but otherwise
62
+ /// continue operating if possible.
63
+ offline : bool ,
59
64
/// A global static IPC control mechanism (used for managing parallel builds)
60
65
jobserver : Option < jobserver:: Client > ,
61
66
/// Cli flags of the form "-Z something"
@@ -119,6 +124,7 @@ impl Config {
119
124
extra_verbose : false ,
120
125
frozen : false ,
121
126
locked : false ,
127
+ offline : false ,
122
128
jobserver : unsafe {
123
129
if GLOBAL_JOBSERVER . is_null ( ) {
124
130
None
@@ -560,6 +566,7 @@ impl Config {
560
566
color : & Option < String > ,
561
567
frozen : bool ,
562
568
locked : bool ,
569
+ offline : bool ,
563
570
target_dir : & Option < PathBuf > ,
564
571
unstable_flags : & [ String ] ,
565
572
) -> CargoResult < ( ) > {
@@ -604,6 +611,11 @@ impl Config {
604
611
self . extra_verbose = extra_verbose;
605
612
self . frozen = frozen;
606
613
self . locked = locked;
614
+ self . offline = offline
615
+ || self
616
+ . get :: < Option < bool > > ( "net.offline" )
617
+ . unwrap_or ( None )
618
+ . unwrap_or ( false ) ;
607
619
self . target_dir = cli_target_dir;
608
620
self . cli_flags . parse ( unstable_flags) ?;
609
621
@@ -619,7 +631,11 @@ impl Config {
619
631
}
620
632
621
633
pub fn network_allowed ( & self ) -> bool {
622
- !self . frozen ( ) && !self . cli_unstable ( ) . offline
634
+ !self . frozen ( ) && !self . offline ( )
635
+ }
636
+
637
+ pub fn offline ( & self ) -> bool {
638
+ self . offline
623
639
}
624
640
625
641
pub fn frozen ( & self ) -> bool {
0 commit comments