def _get_file_exists_uncached(self, path, revision, base_commit_id, request): """Internal function for checking that a file exists. This is called by get_file_eixsts if the file isn't already in the cache. This function is smart enough to check if the file exists in cache, and will use that for the result instead of making a separate call. """ # First we check to see if we've fetched the file before. If so, # it's in there and we can just return that we have it. file_cache_key = make_cache_key(self._make_file_cache_key(path, revision, base_commit_id)) if file_cache_key in cache: exists = True else: # We didn't have that in the cache, so check from the repository. checking_file_exists.send( sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request ) hosting_service = self.hosting_service if hosting_service: exists = hosting_service.get_file_exists(self, path, revision, base_commit_id=base_commit_id) else: exists = self.get_scmtool().file_exists(path, revision) checked_file_exists.send( sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request, exists=exists ) return exists
def _get_file_exists_uncached(self, path, revision, request): """Internal function for checking that a file exists. This is called by get_file_eixsts if the file isn't already in the cache. This function is smart enough to check if the file exists in cache, and will use that for the result instead of making a separate call. """ # First we check to see if we've fetched the file before. If so, # it's in there and we can just return that we have it. file_cache_key = make_cache_key(self._make_file_cache_key(path, revision)) if cache.has_key(file_cache_key): exists = True else: # We didn't have that in the cache, so check from the repository. checking_file_exists.send(sender=self, path=path, revision=revision, request=request) hosting_service = self.hosting_service if hosting_service: exists = hosting_service.get_file_exists(self, path, revision) else: exists = self.get_scmtool().file_exists(path, revision) checked_file_exists.send(sender=self, path=path, revision=revision, request=request, exists=exists) # We're expected to return a string for cache_memoize, so serialize # this as small as possible. if exists: return "1" else: return "0"
def _get_file_exists_uncached(self, path, revision, base_commit_id, request): """Internal function for checking that a file exists. This is called by get_file_exists if the file isn't already in the cache. This function is smart enough to check if the file exists in cache, and will use that for the result instead of making a separate call. """ # First we check to see if we've fetched the file before. If so, # it's in there and we can just return that we have it. file_cache_key = make_cache_key( self._make_file_cache_key(path, revision, base_commit_id)) if file_cache_key in cache: exists = True else: # We didn't have that in the cache, so check from the repository. checking_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request) hosting_service = self.hosting_service if hosting_service: exists = hosting_service.get_file_exists( self, path, revision, base_commit_id=base_commit_id) else: tool = self.get_scmtool() argspec = inspect.getargspec(tool.file_exists) if argspec.keywords is None: warnings.warn('SCMTool.file_exists() must take keyword ' 'arguments, signature for %s is deprecated.' % tool.name, RemovedInReviewBoard40Warning) exists = tool.file_exists(path, revision) else: exists = tool.file_exists(path, revision, base_commit_id=base_commit_id) checked_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request, exists=exists) return exists
def _get_file_exists_uncached(self, path, revision, base_commit_id, request): """Check for file existence, bypassing cache. This is called internally by :py:meth:`get_file_exists` if the file isn't already in the cache. This function is smart enough to check if the file exists in cache, and will use that for the result instead of making a separate call. This will send the :py:data:`~reviewboard.scmtools.signals.checking_file_exists` signal before beginning a file fetch from the repository, and the :py:data:`~reviewboard.scmtools.signals.checked_file_exists` signal after. """ # First we check to see if we've fetched the file before. If so, # it's in there and we can just return that we have it. file_cache_key = make_cache_key( self._make_file_cache_key(path, revision, base_commit_id)) if file_cache_key in cache: exists = True else: # We didn't have that in the cache, so check from the repository. checking_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request) hosting_service = self.hosting_service if hosting_service: exists = hosting_service.get_file_exists( self, path, revision, base_commit_id=base_commit_id) else: tool = self.get_scmtool() exists = tool.file_exists(path, revision, base_commit_id=base_commit_id) checked_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request, exists=exists) return exists
def _get_file_exists_uncached(self, path, revision, base_commit_id, request): """Internal function for checking that a file exists. This is called by get_file_exists if the file isn't already in the cache. This function is smart enough to check if the file exists in cache, and will use that for the result instead of making a separate call. """ # First we check to see if we've fetched the file before. If so, # it's in there and we can just return that we have it. file_cache_key = make_cache_key( self._make_file_cache_key(path, revision, base_commit_id)) if file_cache_key in cache: exists = True else: # We didn't have that in the cache, so check from the repository. checking_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request) hosting_service = self.hosting_service if hosting_service: exists = hosting_service.get_file_exists( self, path, revision, base_commit_id=base_commit_id) else: tool = self.get_scmtool() exists = tool.file_exists(path, revision, base_commit_id=base_commit_id) checked_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request, exists=exists) return exists
def _get_file_exists_uncached(self, path, revision, context): """Check for file existence, bypassing cache. This is called internally by :py:meth:`get_file_exists` if the file isn't already in the cache. This function is smart enough to check if the file exists in cache, and will use that for the result instead of making a separate call. This will send the :py:data:`~reviewboard.scmtools.signals.checking_file_exists` signal before beginning a file fetch from the repository, and the :py:data:`~reviewboard.scmtools.signals.checked_file_exists` signal after. Args: path (unicode): The path to the file in the repository. revision (unicode): The revision of the file to check. context (reviewboard.scmtools.core.FileLookupContext): Extra context used to help look up this file. Version Added: 4.0.5 Returns: bool: ``True`` if the file exists. ``False`` if it does not. """ request = context.request base_commit_id = context.base_commit_id # First we check to see if we've fetched the file before. If so, # it's in there and we can just return that we have it. file_cache_key = make_cache_key( self._make_file_cache_key(path=path, revision=revision, base_commit_id=base_commit_id)) if file_cache_key in cache: exists = True else: # We didn't have that in the cache, so check from the repository. checking_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request, context=context) hosting_service = self.hosting_service if hosting_service: exists = hosting_service.get_file_exists( self, path, revision, base_commit_id=base_commit_id, context=context) else: tool = self.get_scmtool() exists = tool.file_exists(path, revision, base_commit_id=base_commit_id, context=context) checked_file_exists.send(sender=self, path=path, revision=revision, base_commit_id=base_commit_id, request=request, exists=exists, context=context) return exists