edcd459b9cf96c3e5ffc8d6965df5f2e731b3b84,src/python/pants/cache/restful_artifact_cache.py,RESTfulArtifactCache,use_cached_files,#RESTfulArtifactCache#Any#,65

Before Change


    try:
      // Send an HTTP request for the tarball.
      response = self._request("GET", remote_path)
      if response is None:
        return None

      with temporary_file() as outfile:
        total_bytes = 0
        // Read the data in a loop.
        for chunk in response.iter_content(self.READ_SIZE_BYTES):
          outfile.write(chunk)
          total_bytes += len(chunk)

        outfile.close()
        self.log.debug("Read %d bytes from artifact cache at %s" %
                       (total_bytes,self._url_string(remote_path)))

        // Extract the tarfile.
        artifact = TarballArtifact(self.artifact_root, outfile.name, self.compression)
        artifact.extract()
        return artifact
    except Exception as e:
      self.log.warn("Error while reading from remote artifact cache: %s" % e)
      return None

After Change


    return self._request("HEAD", self._remote_path_for_key(cache_key)) is not None

  def use_cached_files(self, cache_key):
    if self._localcache.has(cache_key):
      return self._localcache.use_cached_files(cache_key)

    remote_path = self._remote_path_for_key(cache_key)
    try:
      response = self._request("GET", remote_path)
      if response is not None:
        // Delegate storage and extraction to local cache
        byte_iter = response.iter_content(self.READ_SIZE_BYTES)
        return self._localcache.store_and_use_artifact(cache_key, byte_iter)
    except Exception as e:
      logger.warn("\nError while reading from remote artifact cache: {0}\n".format(e))

    return False
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: pantsbuild/pants
Commit Name: edcd459b9cf96c3e5ffc8d6965df5f2e731b3b84
Time: 2014-10-30
Author: tinystatemachine@gmail.com
File Name: src/python/pants/cache/restful_artifact_cache.py
Class Name: RESTfulArtifactCache
Method Name: use_cached_files


Project Name: pantsbuild/pants
Commit Name: aea2747cda25271b788d670b8e65452b24bed4e0
Time: 2015-09-17
Author: john.sirois@gmail.com
File Name: src/python/pants/backend/android/tasks/unpack_libraries.py
Class Name: UnpackLibraries
Method Name: _unpack_artifacts


Project Name: dmlc/gluon-cv
Commit Name: 2716ec90b5be79d67cb39c46f1182b9827fa60bc
Time: 2020-05-03
Author: 42975160+HieronymusLex@users.noreply.github.com
File Name: scripts/datasets/market1501.py
Class Name:
Method Name: main