Ejemplo n.º 1
0
  def rename(self, old, new):
    try:
      # Replace the full name of the friend by its uid within the path
      new = self.hackedPath(new)

      remote = rpc.Server(config.sync_host, KerbTransport())
      owner  = os.environ['USER'].encode('utf8')

      friend_uid = os.path.basename(os.path.dirname(new))
      friend = utils.get_user_infos(uid=int(friend_uid))['login']

      document = self._syncDocs.by_path(key=self.overlayPath(old), pk=True)

      self.debug("Sharing file %s from '%s' to '%s'" % (document.id, owner, friend))

      try:
        remote.sync.add_new_share(friend, document.id, "R")
      except rpc.Fault, f:
        raise utils.fault_to_exception(f)

    except AlreadySharedDocError, e:
      raise OSError(errno.EEXIST, str(e))
Ejemplo n.º 2
0
  def removeCachedFile(self, path, removeperm=False):
    try:
      # Replace the full name of the friend by its uid within the path.
      uidpath = self.hackedPath(path)

      # Here we want to remove a file that correspond to an active
      # share with a friend.
      if self.isFileLevel(path):
        remote = rpc.Server(config.sync_host, KerbTransport())
        owner  = unicode(os.environ['USER'], "utf8")

        friend_uid = uidpath.split(os.sep)[1]
        friend = utils.get_user_infos(uid=int(friend_uid))['login']

        document = self._syncDocs.by_path(key=self.realFilePath(path), pk=True)

        self.debug("%s remove %s from the share of '%s'" % (owner, friend, document.id))

        try:
          remote.sync.remove_participant_from_share(friend, document.id)
        except rpc.Fault, f:
          raise utils.fault_to_exception(f)

      else: