X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2bef371e8429430942193fff02599ec51c081e70..8f987a9271eda80697b3a8fc53e7ebb0f93816f9:/sdk/python/arvados/commands/put.py?ds=sidebyside diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py index 3a669297ef..ec4ae8fb6f 100644 --- a/sdk/python/arvados/commands/put.py +++ b/sdk/python/arvados/commands/put.py @@ -710,6 +710,7 @@ class ArvPutUploadJob(object): elif file_in_local_collection.permission_expired(): # Permission token expired, re-upload file. This will change whenever # we have a API for refreshing tokens. + self.logger.warning("Uploaded file '{}' access token expired, will re-upload it from scratch".format(filename)) should_upload = True self._local_collection.remove(filename) elif cached_file_data['size'] == file_in_local_collection.size(): @@ -796,16 +797,8 @@ class ArvPutUploadJob(object): arv_cmd.make_home_conf_dir(self.CACHE_DIR, 0o700, 'raise'), cache_filename) if self.resume and os.path.exists(cache_filepath): - if self._cache_is_valid(cache_filepath): - self.logger.info( - "Resuming upload from cache file {}".format( - cache_filepath)) - self._cache_file = open(cache_filepath, 'a+') - else: - self.logger.info( - "Cache file {} is not valid, starting from scratch".format( - cache_filepath)) - self._cache_file = open(cache_filepath, 'w+') + self.logger.info("Resuming upload from cache file {}".format(cache_filepath)) + self._cache_file = open(cache_filepath, 'a+') else: # --no-resume means start with a empty cache file. self.logger.info("Creating new cache file at {}".format(cache_filepath)) @@ -831,23 +824,6 @@ class ArvPutUploadJob(object): # Load the previous manifest so we can check if files were modified remotely. self._local_collection = arvados.collection.Collection(self._state['manifest'], replication_desired=self.replication_desired, put_threads=self.put_threads) - def _cache_is_valid(self, filepath): - try: - with open(filepath, 'r') as cache_file: - manifest = json.load(cache_file)['manifest'] - kc = arvados.keep.KeepClient(api_client=api_client) - # Check that the first block's token (oldest) is valid - for line in manifest.split('\n'): - match = arvados.util.signed_locator_pattern.search(line) - if match is not None: - loc = match.group(0) - return kc.head(loc, num_retries=self.num_retries) - # No signed locator found, all ok. - return True - except Exception as e: - self.logger.info("Something wrong happened when checking cache file: {}".format(e)) - return False - def collection_file_paths(self, col, path_prefix='.'): """Return a list of file paths by recursively go through the entire collection `col`""" file_paths = []