code: func (c *InstanceCache) readState(ctx context.Context, state *messages.InstanceCache, now time.Time) {
  	statePath, err := c.fs.RootRelToAbs(instanceCacheStateFilename)
  	if err != nil {
  		panic("impossible")
  	}
  
  	stateBytes, err := ioutil.ReadFile(statePath)
  	sync := false
  	switch {
  	case os.IsNotExist(err):
  		sync = true
  
  	case err != nil:
  		logging.Warningf(ctx, "cipd: could not read instance cache - %s", err)
  		sync = true
  
  	default:
  		if err := UnmarshalWithSHA256(stateBytes, state); err != nil {
  			if err == ErrUnknownSHA256 {
  				logging.Warningf(ctx, "cipd: need to rebuild instance cache index file")
  			} else {
  				logging.Warningf(ctx, "cipd: instance cache file is corrupted - %s", err)
  			}
  			*state = messages.InstanceCache{}
  			sync = true
  		} else {
  			cutOff := now.
  				Add(-instanceCacheSyncInterval).
  				Add(time.Duration(rand.Int63n(int64(5 * time.Minute))))
  			sync = google.TimeFromProto(state.LastSynced).Before(cutOff)
  		}
  	}
  
  	if sync {
  		if err := c.syncState(ctx, state, now); err != nil {
  			logging.Warningf(ctx, "cipd: failed to sync instance cache - %s", err)
  		}
  		c.gc(ctx, state, now)
  	}
  }
docs: // readState loads cache state from the state file.
  // If the file does not exist, corrupted or its state was not synchronized
  // with the instance files for a long time, synchronizes it.
  // Newly discovered files are considered last accessed at zero time.
  // If synchronization fails, then the state is considered empty.