Example #1
0
 def translatePath(self, path):
     """Translate 'path'."""
     try:
         return defer.succeed(self._getFromCache(path))
     except NotInCache:
         deferred = self._codehosting_endpoint.callRemote(
             'translatePath', self._user_id, path)
         deferred.addCallback(no_traceback_failures(self._addToCache), path)
         return deferred
 def translatePath(self, path):
     """Translate 'path'."""
     try:
         return defer.succeed(self._getFromCache(path))
     except NotInCache:
         deferred = self._codehosting_endpoint.callRemote(
             'translatePath', self._user_id, path)
         deferred.addCallback(no_traceback_failures(self._addToCache), path)
         return deferred
Example #3
0
 def rename(self, rel_from, rel_to):
     # We hook into rename to catch the "unlock branch" event, so that we
     # can request a mirror once a branch is unlocked.
     abs_from = self._abspath(rel_from)
     if is_lock_directory(abs_from):
         deferred = self.server.branchChanged(abs_from)
     else:
         deferred = defer.succeed(None)
     deferred = deferred.addCallback(
         no_traceback_failures(lambda ignored: AsyncVirtualTransport.rename(self, rel_from, rel_to))
     )
     return deferred
Example #4
0
 def rename(self, rel_from, rel_to):
     # We hook into rename to catch the "unlock branch" event, so that we
     # can request a mirror once a branch is unlocked.
     abs_from = self._abspath(rel_from)
     if is_lock_directory(abs_from):
         deferred = self.server.branchChanged(abs_from)
     else:
         deferred = defer.succeed(None)
     deferred = deferred.addCallback(
         no_traceback_failures(lambda ignored: AsyncVirtualTransport.rename(
             self, rel_from, rel_to)))
     return deferred
Example #5
0
    def translateVirtualPath(self, virtual_url_fragment):
        """See `AsyncVirtualServer.translateVirtualPath`.

        Call 'translatePath' on the branchfs client with the fragment and then
        use 'makeTransport' on the _transport_dispatch to translate that
        result into a transport and trailing path.
        """
        deferred = self._branchfs_client.translatePath("/" + virtual_url_fragment)

        def path_not_translated(fail):
            trap_fault(fail, faults.PathTranslationError, faults.PermissionDenied)
            return failure.Failure(NoSuchFile(virtual_url_fragment))

        def unknown_transport_type(fail):
            fail.trap(UnknownTransportType)
            return failure.Failure(NoSuchFile(virtual_url_fragment))

        deferred.addCallbacks(no_traceback_failures(self._transport_dispatch.makeTransport), path_not_translated)
        deferred.addErrback(unknown_transport_type)
        return deferred
Example #6
0
    def translateVirtualPath(self, virtual_url_fragment):
        """See `AsyncVirtualServer.translateVirtualPath`.

        Call 'translatePath' on the branchfs client with the fragment and then
        use 'makeTransport' on the _transport_dispatch to translate that
        result into a transport and trailing path.
        """
        deferred = self._branchfs_client.translatePath('/' +
                                                       virtual_url_fragment)

        def path_not_translated(fail):
            trap_fault(fail, faults.PathTranslationError,
                       faults.PermissionDenied)
            return failure.Failure(NoSuchFile(virtual_url_fragment))

        def unknown_transport_type(fail):
            fail.trap(UnknownTransportType)
            return failure.Failure(NoSuchFile(virtual_url_fragment))

        deferred.addCallbacks(
            no_traceback_failures(self._transport_dispatch.makeTransport),
            path_not_translated)
        deferred.addErrback(unknown_transport_type)
        return deferred