...

Source file src/golang.org/x/mod/sumdb/client.go

Documentation: golang.org/x/mod/sumdb

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package sumdb
     6  
     7  import (
     8  	"bytes"
     9  	"errors"
    10  	"fmt"
    11  	"strings"
    12  	"sync"
    13  	"sync/atomic"
    14  
    15  	"golang.org/x/mod/module"
    16  	"golang.org/x/mod/sumdb/note"
    17  	"golang.org/x/mod/sumdb/tlog"
    18  )
    19  
    20  // A ClientOps provides the external operations
    21  // (file caching, HTTP fetches, and so on) needed by the [Client].
    22  // The methods must be safe for concurrent use by multiple goroutines.
    23  type ClientOps interface {
    24  	// ReadRemote reads and returns the content served at the given path
    25  	// on the remote database server. The path begins with "/lookup" or "/tile/",
    26  	// and there is no need to parse the path in any way.
    27  	// It is the implementation's responsibility to turn that path into a full URL
    28  	// and make the HTTP request. ReadRemote should return an error for
    29  	// any non-200 HTTP response status.
    30  	ReadRemote(path string) ([]byte, error)
    31  
    32  	// ReadConfig reads and returns the content of the named configuration file.
    33  	// There are only a fixed set of configuration files.
    34  	//
    35  	// "key" returns a file containing the verifier key for the server.
    36  	//
    37  	// serverName + "/latest" returns a file containing the latest known
    38  	// signed tree from the server.
    39  	// To signal that the client wishes to start with an "empty" signed tree,
    40  	// ReadConfig can return a successful empty result (0 bytes of data).
    41  	ReadConfig(file string) ([]byte, error)
    42  
    43  	// WriteConfig updates the content of the named configuration file,
    44  	// changing it from the old []byte to the new []byte.
    45  	// If the old []byte does not match the stored configuration,
    46  	// WriteConfig must return ErrWriteConflict.
    47  	// Otherwise, WriteConfig should atomically replace old with new.
    48  	// The "key" configuration file is never written using WriteConfig.
    49  	WriteConfig(file string, old, new []byte) error
    50  
    51  	// ReadCache reads and returns the content of the named cache file.
    52  	// Any returned error will be treated as equivalent to the file not existing.
    53  	// There can be arbitrarily many cache files, such as:
    54  	//	serverName/lookup/pkg@version
    55  	//	serverName/tile/8/1/x123/456
    56  	ReadCache(file string) ([]byte, error)
    57  
    58  	// WriteCache writes the named cache file.
    59  	WriteCache(file string, data []byte)
    60  
    61  	// Log prints the given log message (such as with log.Print)
    62  	Log(msg string)
    63  
    64  	// SecurityError prints the given security error log message.
    65  	// The Client returns ErrSecurity from any operation that invokes SecurityError,
    66  	// but the return value is mainly for testing. In a real program,
    67  	// SecurityError should typically print the message and call log.Fatal or os.Exit.
    68  	SecurityError(msg string)
    69  }
    70  
    71  // ErrWriteConflict signals a write conflict during Client.WriteConfig.
    72  var ErrWriteConflict = errors.New("write conflict")
    73  
    74  // ErrSecurity is returned by [Client] operations that invoke Client.SecurityError.
    75  var ErrSecurity = errors.New("security error: misbehaving server")
    76  
    77  // A Client is a client connection to a checksum database.
    78  // All the methods are safe for simultaneous use by multiple goroutines.
    79  type Client struct {
    80  	ops ClientOps // access to operations in the external world
    81  
    82  	didLookup uint32
    83  
    84  	// one-time initialized data
    85  	initOnce   sync.Once
    86  	initErr    error          // init error, if any
    87  	name       string         // name of accepted verifier
    88  	verifiers  note.Verifiers // accepted verifiers (just one, but Verifiers for note.Open)
    89  	tileReader tileReader
    90  	tileHeight int
    91  	nosumdb    string
    92  
    93  	record    parCache // cache of record lookup, keyed by path@vers
    94  	tileCache parCache // cache of c.readTile, keyed by tile
    95  
    96  	latestMu  sync.Mutex
    97  	latest    tlog.Tree // latest known tree head
    98  	latestMsg []byte    // encoded signed note for latest
    99  
   100  	tileSavedMu sync.Mutex
   101  	tileSaved   map[tlog.Tile]bool // which tiles have been saved using c.ops.WriteCache already
   102  }
   103  
   104  // NewClient returns a new [Client] using the given [ClientOps].
   105  func NewClient(ops ClientOps) *Client {
   106  	return &Client{
   107  		ops: ops,
   108  	}
   109  }
   110  
   111  // init initializes the client (if not already initialized)
   112  // and returns any initialization error.
   113  func (c *Client) init() error {
   114  	c.initOnce.Do(c.initWork)
   115  	return c.initErr
   116  }
   117  
   118  // initWork does the actual initialization work.
   119  func (c *Client) initWork() {
   120  	defer func() {
   121  		if c.initErr != nil {
   122  			c.initErr = fmt.Errorf("initializing sumdb.Client: %v", c.initErr)
   123  		}
   124  	}()
   125  
   126  	c.tileReader.c = c
   127  	if c.tileHeight == 0 {
   128  		c.tileHeight = 8
   129  	}
   130  	c.tileSaved = make(map[tlog.Tile]bool)
   131  
   132  	vkey, err := c.ops.ReadConfig("key")
   133  	if err != nil {
   134  		c.initErr = err
   135  		return
   136  	}
   137  	verifier, err := note.NewVerifier(strings.TrimSpace(string(vkey)))
   138  	if err != nil {
   139  		c.initErr = err
   140  		return
   141  	}
   142  	c.verifiers = note.VerifierList(verifier)
   143  	c.name = verifier.Name()
   144  
   145  	data, err := c.ops.ReadConfig(c.name + "/latest")
   146  	if err != nil {
   147  		c.initErr = err
   148  		return
   149  	}
   150  	if err := c.mergeLatest(data); err != nil {
   151  		c.initErr = err
   152  		return
   153  	}
   154  }
   155  
   156  // SetTileHeight sets the tile height for the Client.
   157  // Any call to SetTileHeight must happen before the first call to [Client.Lookup].
   158  // If SetTileHeight is not called, the Client defaults to tile height 8.
   159  // SetTileHeight can be called at most once,
   160  // and if so it must be called before the first call to Lookup.
   161  func (c *Client) SetTileHeight(height int) {
   162  	if atomic.LoadUint32(&c.didLookup) != 0 {
   163  		panic("SetTileHeight used after Lookup")
   164  	}
   165  	if height <= 0 {
   166  		panic("invalid call to SetTileHeight")
   167  	}
   168  	if c.tileHeight != 0 {
   169  		panic("multiple calls to SetTileHeight")
   170  	}
   171  	c.tileHeight = height
   172  }
   173  
   174  // SetGONOSUMDB sets the list of comma-separated GONOSUMDB patterns for the Client.
   175  // For any module path matching one of the patterns,
   176  // [Client.Lookup] will return ErrGONOSUMDB.
   177  // SetGONOSUMDB can be called at most once,
   178  // and if so it must be called before the first call to Lookup.
   179  func (c *Client) SetGONOSUMDB(list string) {
   180  	if atomic.LoadUint32(&c.didLookup) != 0 {
   181  		panic("SetGONOSUMDB used after Lookup")
   182  	}
   183  	if c.nosumdb != "" {
   184  		panic("multiple calls to SetGONOSUMDB")
   185  	}
   186  	c.nosumdb = list
   187  }
   188  
   189  // ErrGONOSUMDB is returned by [Client.Lookup] for paths that match
   190  // a pattern listed in the GONOSUMDB list (set by [Client.SetGONOSUMDB],
   191  // usually from the environment variable).
   192  var ErrGONOSUMDB = errors.New("skipped (listed in GONOSUMDB)")
   193  
   194  func (c *Client) skip(target string) bool {
   195  	return module.MatchPrefixPatterns(c.nosumdb, target)
   196  }
   197  
   198  // Lookup returns the go.sum lines for the given module path and version.
   199  // The version may end in a /go.mod suffix, in which case Lookup returns
   200  // the go.sum lines for the module's go.mod-only hash.
   201  func (c *Client) Lookup(path, vers string) (lines []string, err error) {
   202  	atomic.StoreUint32(&c.didLookup, 1)
   203  
   204  	if c.skip(path) {
   205  		return nil, ErrGONOSUMDB
   206  	}
   207  
   208  	defer func() {
   209  		if err != nil {
   210  			err = fmt.Errorf("%s@%s: %v", path, vers, err)
   211  		}
   212  	}()
   213  
   214  	if err := c.init(); err != nil {
   215  		return nil, err
   216  	}
   217  
   218  	// Prepare encoded cache filename / URL.
   219  	epath, err := module.EscapePath(path)
   220  	if err != nil {
   221  		return nil, err
   222  	}
   223  	evers, err := module.EscapeVersion(strings.TrimSuffix(vers, "/go.mod"))
   224  	if err != nil {
   225  		return nil, err
   226  	}
   227  	remotePath := "/lookup/" + epath + "@" + evers
   228  	file := c.name + remotePath
   229  
   230  	// Fetch the data.
   231  	// The lookupCache avoids redundant ReadCache/GetURL operations
   232  	// (especially since go.sum lines tend to come in pairs for a given
   233  	// path and version) and also avoids having multiple of the same
   234  	// request in flight at once.
   235  	type cached struct {
   236  		data []byte
   237  		err  error
   238  	}
   239  	result := c.record.Do(file, func() interface{} {
   240  		// Try the on-disk cache, or else get from web.
   241  		writeCache := false
   242  		data, err := c.ops.ReadCache(file)
   243  		if err != nil {
   244  			data, err = c.ops.ReadRemote(remotePath)
   245  			if err != nil {
   246  				return cached{nil, err}
   247  			}
   248  			writeCache = true
   249  		}
   250  
   251  		// Validate the record before using it for anything.
   252  		id, text, treeMsg, err := tlog.ParseRecord(data)
   253  		if err != nil {
   254  			return cached{nil, err}
   255  		}
   256  		if err := c.mergeLatest(treeMsg); err != nil {
   257  			return cached{nil, err}
   258  		}
   259  		if err := c.checkRecord(id, text); err != nil {
   260  			return cached{nil, err}
   261  		}
   262  
   263  		// Now that we've validated the record,
   264  		// save it to the on-disk cache (unless that's where it came from).
   265  		if writeCache {
   266  			c.ops.WriteCache(file, data)
   267  		}
   268  
   269  		return cached{data, nil}
   270  	}).(cached)
   271  	if result.err != nil {
   272  		return nil, result.err
   273  	}
   274  
   275  	// Extract the lines for the specific version we want
   276  	// (with or without /go.mod).
   277  	prefix := path + " " + vers + " "
   278  	var hashes []string
   279  	for _, line := range strings.Split(string(result.data), "\n") {
   280  		if strings.HasPrefix(line, prefix) {
   281  			hashes = append(hashes, line)
   282  		}
   283  	}
   284  	return hashes, nil
   285  }
   286  
   287  // mergeLatest merges the tree head in msg
   288  // with the Client's current latest tree head,
   289  // ensuring the result is a consistent timeline.
   290  // If the result is inconsistent, mergeLatest calls c.ops.SecurityError
   291  // with a detailed security error message and then
   292  // (only if c.ops.SecurityError does not exit the program) returns ErrSecurity.
   293  // If the Client's current latest tree head moves forward,
   294  // mergeLatest updates the underlying configuration file as well,
   295  // taking care to merge any independent updates to that configuration.
   296  func (c *Client) mergeLatest(msg []byte) error {
   297  	// Merge msg into our in-memory copy of the latest tree head.
   298  	when, err := c.mergeLatestMem(msg)
   299  	if err != nil {
   300  		return err
   301  	}
   302  	if when != msgFuture {
   303  		// msg matched our present or was in the past.
   304  		// No change to our present, so no update of config file.
   305  		return nil
   306  	}
   307  
   308  	// Flush our extended timeline back out to the configuration file.
   309  	// If the configuration file has been updated in the interim,
   310  	// we need to merge any updates made there as well.
   311  	// Note that writeConfig is an atomic compare-and-swap.
   312  	for {
   313  		msg, err := c.ops.ReadConfig(c.name + "/latest")
   314  		if err != nil {
   315  			return err
   316  		}
   317  		when, err := c.mergeLatestMem(msg)
   318  		if err != nil {
   319  			return err
   320  		}
   321  		if when != msgPast {
   322  			// msg matched our present or was from the future,
   323  			// and now our in-memory copy matches.
   324  			return nil
   325  		}
   326  
   327  		// msg (== config) is in the past, so we need to update it.
   328  		c.latestMu.Lock()
   329  		latestMsg := c.latestMsg
   330  		c.latestMu.Unlock()
   331  		if err := c.ops.WriteConfig(c.name+"/latest", msg, latestMsg); err != ErrWriteConflict {
   332  			// Success or a non-write-conflict error.
   333  			return err
   334  		}
   335  	}
   336  }
   337  
   338  const (
   339  	msgPast = 1 + iota
   340  	msgNow
   341  	msgFuture
   342  )
   343  
   344  // mergeLatestMem is like mergeLatest but is only concerned with
   345  // updating the in-memory copy of the latest tree head (c.latest)
   346  // not the configuration file.
   347  // The when result explains when msg happened relative to our
   348  // previous idea of c.latest:
   349  // msgPast means msg was from before c.latest,
   350  // msgNow means msg was exactly c.latest, and
   351  // msgFuture means msg was from after c.latest, which has now been updated.
   352  func (c *Client) mergeLatestMem(msg []byte) (when int, err error) {
   353  	if len(msg) == 0 {
   354  		// Accept empty msg as the unsigned, empty timeline.
   355  		c.latestMu.Lock()
   356  		latest := c.latest
   357  		c.latestMu.Unlock()
   358  		if latest.N == 0 {
   359  			return msgNow, nil
   360  		}
   361  		return msgPast, nil
   362  	}
   363  
   364  	note, err := note.Open(msg, c.verifiers)
   365  	if err != nil {
   366  		return 0, fmt.Errorf("reading tree note: %v\nnote:\n%s", err, msg)
   367  	}
   368  	tree, err := tlog.ParseTree([]byte(note.Text))
   369  	if err != nil {
   370  		return 0, fmt.Errorf("reading tree: %v\ntree:\n%s", err, note.Text)
   371  	}
   372  
   373  	// Other lookups may be calling mergeLatest with other heads,
   374  	// so c.latest is changing underfoot. We don't want to hold the
   375  	// c.mu lock during tile fetches, so loop trying to update c.latest.
   376  	c.latestMu.Lock()
   377  	latest := c.latest
   378  	latestMsg := c.latestMsg
   379  	c.latestMu.Unlock()
   380  
   381  	for {
   382  		// If the tree head looks old, check that it is on our timeline.
   383  		if tree.N <= latest.N {
   384  			if err := c.checkTrees(tree, msg, latest, latestMsg); err != nil {
   385  				return 0, err
   386  			}
   387  			if tree.N < latest.N {
   388  				return msgPast, nil
   389  			}
   390  			return msgNow, nil
   391  		}
   392  
   393  		// The tree head looks new. Check that we are on its timeline and try to move our timeline forward.
   394  		if err := c.checkTrees(latest, latestMsg, tree, msg); err != nil {
   395  			return 0, err
   396  		}
   397  
   398  		// Install our msg if possible.
   399  		// Otherwise we will go around again.
   400  		c.latestMu.Lock()
   401  		installed := false
   402  		if c.latest == latest {
   403  			installed = true
   404  			c.latest = tree
   405  			c.latestMsg = msg
   406  		} else {
   407  			latest = c.latest
   408  			latestMsg = c.latestMsg
   409  		}
   410  		c.latestMu.Unlock()
   411  
   412  		if installed {
   413  			return msgFuture, nil
   414  		}
   415  	}
   416  }
   417  
   418  // checkTrees checks that older (from olderNote) is contained in newer (from newerNote).
   419  // If an error occurs, such as malformed data or a network problem, checkTrees returns that error.
   420  // If on the other hand checkTrees finds evidence of misbehavior, it prepares a detailed
   421  // message and calls log.Fatal.
   422  func (c *Client) checkTrees(older tlog.Tree, olderNote []byte, newer tlog.Tree, newerNote []byte) error {
   423  	thr := tlog.TileHashReader(newer, &c.tileReader)
   424  	h, err := tlog.TreeHash(older.N, thr)
   425  	if err != nil {
   426  		if older.N == newer.N {
   427  			return fmt.Errorf("checking tree#%d: %v", older.N, err)
   428  		}
   429  		return fmt.Errorf("checking tree#%d against tree#%d: %v", older.N, newer.N, err)
   430  	}
   431  	if h == older.Hash {
   432  		return nil
   433  	}
   434  
   435  	// Detected a fork in the tree timeline.
   436  	// Start by reporting the inconsistent signed tree notes.
   437  	var buf bytes.Buffer
   438  	fmt.Fprintf(&buf, "SECURITY ERROR\n")
   439  	fmt.Fprintf(&buf, "go.sum database server misbehavior detected!\n\n")
   440  	indent := func(b []byte) []byte {
   441  		return bytes.Replace(b, []byte("\n"), []byte("\n\t"), -1)
   442  	}
   443  	fmt.Fprintf(&buf, "old database:\n\t%s\n", indent(olderNote))
   444  	fmt.Fprintf(&buf, "new database:\n\t%s\n", indent(newerNote))
   445  
   446  	// The notes alone are not enough to prove the inconsistency.
   447  	// We also need to show that the newer note's tree hash for older.N
   448  	// does not match older.Hash. The consumer of this report could
   449  	// of course consult the server to try to verify the inconsistency,
   450  	// but we are holding all the bits we need to prove it right now,
   451  	// so we might as well print them and make the report not depend
   452  	// on the continued availability of the misbehaving server.
   453  	// Preparing this data only reuses the tiled hashes needed for
   454  	// tlog.TreeHash(older.N, thr) above, so assuming thr is caching tiles,
   455  	// there are no new access to the server here, and these operations cannot fail.
   456  	fmt.Fprintf(&buf, "proof of misbehavior:\n\t%v", h)
   457  	if p, err := tlog.ProveTree(newer.N, older.N, thr); err != nil {
   458  		fmt.Fprintf(&buf, "\tinternal error: %v\n", err)
   459  	} else if err := tlog.CheckTree(p, newer.N, newer.Hash, older.N, h); err != nil {
   460  		fmt.Fprintf(&buf, "\tinternal error: generated inconsistent proof\n")
   461  	} else {
   462  		for _, h := range p {
   463  			fmt.Fprintf(&buf, "\n\t%v", h)
   464  		}
   465  	}
   466  	c.ops.SecurityError(buf.String())
   467  	return ErrSecurity
   468  }
   469  
   470  // checkRecord checks that record #id's hash matches data.
   471  func (c *Client) checkRecord(id int64, data []byte) error {
   472  	c.latestMu.Lock()
   473  	latest := c.latest
   474  	c.latestMu.Unlock()
   475  
   476  	if id >= latest.N {
   477  		return fmt.Errorf("cannot validate record %d in tree of size %d", id, latest.N)
   478  	}
   479  	hashes, err := tlog.TileHashReader(latest, &c.tileReader).ReadHashes([]int64{tlog.StoredHashIndex(0, id)})
   480  	if err != nil {
   481  		return err
   482  	}
   483  	if hashes[0] == tlog.RecordHash(data) {
   484  		return nil
   485  	}
   486  	return fmt.Errorf("cannot authenticate record data in server response")
   487  }
   488  
   489  // tileReader is a *Client wrapper that implements tlog.TileReader.
   490  // The separate type avoids exposing the ReadTiles and SaveTiles
   491  // methods on Client itself.
   492  type tileReader struct {
   493  	c *Client
   494  }
   495  
   496  func (r *tileReader) Height() int {
   497  	return r.c.tileHeight
   498  }
   499  
   500  // ReadTiles reads and returns the requested tiles,
   501  // either from the on-disk cache or the server.
   502  func (r *tileReader) ReadTiles(tiles []tlog.Tile) ([][]byte, error) {
   503  	// Read all the tiles in parallel.
   504  	data := make([][]byte, len(tiles))
   505  	errs := make([]error, len(tiles))
   506  	var wg sync.WaitGroup
   507  	for i, tile := range tiles {
   508  		wg.Add(1)
   509  		go func(i int, tile tlog.Tile) {
   510  			defer wg.Done()
   511  			defer func() {
   512  				if e := recover(); e != nil {
   513  					errs[i] = fmt.Errorf("panic: %v", e)
   514  				}
   515  			}()
   516  			data[i], errs[i] = r.c.readTile(tile)
   517  		}(i, tile)
   518  	}
   519  	wg.Wait()
   520  
   521  	for _, err := range errs {
   522  		if err != nil {
   523  			return nil, err
   524  		}
   525  	}
   526  
   527  	return data, nil
   528  }
   529  
   530  // tileCacheKey returns the cache key for the tile.
   531  func (c *Client) tileCacheKey(tile tlog.Tile) string {
   532  	return c.name + "/" + tile.Path()
   533  }
   534  
   535  // tileRemotePath returns the remote path for the tile.
   536  func (c *Client) tileRemotePath(tile tlog.Tile) string {
   537  	return "/" + tile.Path()
   538  }
   539  
   540  // readTile reads a single tile, either from the on-disk cache or the server.
   541  func (c *Client) readTile(tile tlog.Tile) ([]byte, error) {
   542  	type cached struct {
   543  		data []byte
   544  		err  error
   545  	}
   546  
   547  	result := c.tileCache.Do(tile, func() interface{} {
   548  		// Try the requested tile in on-disk cache.
   549  		data, err := c.ops.ReadCache(c.tileCacheKey(tile))
   550  		if err == nil {
   551  			c.markTileSaved(tile)
   552  			return cached{data, nil}
   553  		}
   554  
   555  		// Try the full tile in on-disk cache (if requested tile not already full).
   556  		// We only save authenticated tiles to the on-disk cache,
   557  		// so the recreated prefix is equally authenticated.
   558  		full := tile
   559  		full.W = 1 << uint(tile.H)
   560  		if tile != full {
   561  			data, err := c.ops.ReadCache(c.tileCacheKey(full))
   562  			if err == nil {
   563  				c.markTileSaved(tile) // don't save tile later; we already have full
   564  				return cached{data[:len(data)/full.W*tile.W], nil}
   565  			}
   566  		}
   567  
   568  		// Try requested tile from server.
   569  		data, err = c.ops.ReadRemote(c.tileRemotePath(tile))
   570  		if err == nil {
   571  			return cached{data, nil}
   572  		}
   573  
   574  		// Try full tile on server.
   575  		// If the partial tile does not exist, it should be because
   576  		// the tile has been completed and only the complete one
   577  		// is available.
   578  		if tile != full {
   579  			data, err := c.ops.ReadRemote(c.tileRemotePath(full))
   580  			if err == nil {
   581  				// Note: We could save the full tile in the on-disk cache here,
   582  				// but we don't know if it is valid yet, and we will only find out
   583  				// about the partial data, not the full data. So let SaveTiles
   584  				// save the partial tile, and we'll just refetch the full tile later
   585  				// once we can validate more (or all) of it.
   586  				return cached{data[:len(data)/full.W*tile.W], nil}
   587  			}
   588  		}
   589  
   590  		// Nothing worked.
   591  		// Return the error from the server fetch for the requested (not full) tile.
   592  		return cached{nil, err}
   593  	}).(cached)
   594  
   595  	return result.data, result.err
   596  }
   597  
   598  // markTileSaved records that tile is already present in the on-disk cache,
   599  // so that a future SaveTiles for that tile can be ignored.
   600  func (c *Client) markTileSaved(tile tlog.Tile) {
   601  	c.tileSavedMu.Lock()
   602  	c.tileSaved[tile] = true
   603  	c.tileSavedMu.Unlock()
   604  }
   605  
   606  // SaveTiles saves the now validated tiles.
   607  func (r *tileReader) SaveTiles(tiles []tlog.Tile, data [][]byte) {
   608  	c := r.c
   609  
   610  	// Determine which tiles need saving.
   611  	// (Tiles that came from the cache need not be saved back.)
   612  	save := make([]bool, len(tiles))
   613  	c.tileSavedMu.Lock()
   614  	for i, tile := range tiles {
   615  		if !c.tileSaved[tile] {
   616  			save[i] = true
   617  			c.tileSaved[tile] = true
   618  		}
   619  	}
   620  	c.tileSavedMu.Unlock()
   621  
   622  	for i, tile := range tiles {
   623  		if save[i] {
   624  			// If WriteCache fails here (out of disk space? i/o error?),
   625  			// c.tileSaved[tile] is still true and we will not try to write it again.
   626  			// Next time we run maybe we'll redownload it again and be
   627  			// more successful.
   628  			c.ops.WriteCache(c.name+"/"+tile.Path(), data[i])
   629  		}
   630  	}
   631  }
   632  

View as plain text