message: Added checked to WranglerVersion struct and added more comments
diff: @@ -20,6 +20,9 @@ pub struct WranglerVersion {
  /// latest version of wrangler on crates.io
  pub latest: Version,
  +
  + /// set to true if wrangler version has been checked within a day
  + pub checked: bool,
  }
  #[derive(Clone, Debug, Deserialize, Serialize)]
  @@ -45,7 +48,7 @@ fn get_installed_version() -> Result<Version, failure::Error> {
  Ok(parsed_version)
  }
  -fn check_wrangler_versions() -> Result<(WranglerVersion, bool), failure::Error> {
  +fn check_wrangler_versions() -> Result<WranglerVersion, failure::Error> {
  let config_dir = get_wrangler_home_dir()?;
  let version_file = config_dir.join("version.toml");
  let current_time = SystemTime::now();
  @@ -57,6 +60,7 @@ fn check_wrangler_versions() -> Result<(WranglerVersion, bool), failure::Error>
  Some(last_checked_version) => {
  let time_since_last_checked =
  current_time.duration_since(last_checked_version.last_checked)?;
  +
  if time_since_last_checked.as_secs() < ONE_DAY {
  checked = true;
  }
  @@ -66,9 +70,14 @@ fn check_wrangler_versions() -> Result<(WranglerVersion, bool), failure::Error>
  None => get_latest_version(&current.to_string(), &version_file, current_time)?,
  };
  - Ok((WranglerVersion { current, latest }, checked))
  + Ok(WranglerVersion {
  + current,
  + latest,
  + checked,
  + })
  }
  +/// Reads version out of version file, is `None` if file does not exist
  fn get_version_disk(version_file: &PathBuf) -> Result<Option<LastCheckedVersion>, failure::Error> {
  let local_version = match fs::read_to_string(&version_file) {
  Ok(contents) => {
  @@ -129,9 +138,11 @@ pub fn background_check_for_updates() -> mpsc::Receiver<Version> {
  let (sender, receiver) = mpsc::channel();
  let _detached_thread = thread::spawn(move || match check_wrangler_versions() {
  - Ok(version) => {
  - let (wrangler_versions, checked) = version;
  - if !checked && (wrangler_versions.current != wrangler_versions.latest) {
  + Ok(wrangler_versions) => {
  + // If the wrangler version has not been checked within the last day and the versions
  + // are different, print out an update message
  + if !wrangler_versions.checked && (wrangler_versions.current != wrangler_versions.latest)
  + {
  let _ = sender.send(wrangler_versions.latest);
  }
  }
  