Revision 2bbf1544 snf-pithos-backend/pithos/backends/lib/sqlite/node.py

b/snf-pithos-backend/pithos/backends/lib/sqlite/node.py
972 972

  
973 973
        return matches, prefixes
974 974

  
975
    def latest_uuid(self, uuid):
976
        """Return a (path, serial) tuple, for the latest version of the given uuid."""
975
    def latest_uuid(self, uuid, cluster):
976
        """Return the latest version of the given uuid and cluster.
977

  
978
        Return a (path, serial) tuple.
979
        If cluster is None, all clusters are considered.
980

  
981
        """
982
        if cluster is not None:
983
            cluster_where = "and cluster = ?"
984
            args = (uuid, int(cluster))
985
        else:
986
            cluster_where = ""
987
            args = (uuid,)
977 988

  
978 989
        q = ("select n.path, v.serial "
979 990
             "from versions v, nodes n "
980 991
             "where v.serial = (select max(serial) "
981 992
             "from versions "
982
             "where uuid = ?) "
983
             "and n.node = v.node")
984
        self.execute(q, (uuid,))
993
             "where uuid = ? %s) "
994
             "and n.node = v.node") % cluster_where
995
        self.execute(q, args)
985 996
        return self.fetchone()

Also available in: Unified diff