Revision 2bbf1544 snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py | ||
---|---|---|
1073 | 1073 |
|
1074 | 1074 |
return matches, prefixes |
1075 | 1075 |
|
1076 |
def latest_uuid(self, uuid): |
|
1077 |
"""Return a (path, serial) tuple, for the latest version of the given uuid.""" |
|
1076 |
def latest_uuid(self, uuid, cluster): |
|
1077 |
"""Return the latest version of the given uuid and cluster. |
|
1078 |
|
|
1079 |
Return a (path, serial) tuple. |
|
1080 |
If cluster is None, all clusters are considered. |
|
1081 |
|
|
1082 |
""" |
|
1078 | 1083 |
|
1079 | 1084 |
v = self.versions.alias('v') |
1080 | 1085 |
n = self.nodes.alias('n') |
1081 | 1086 |
s = select([n.c.path, v.c.serial]) |
1082 | 1087 |
filtered = select([func.max(self.versions.c.serial)]) |
1083 |
s = s.where(v.c.serial == filtered.where(self.versions.c.uuid == uuid)) |
|
1088 |
filtered = filtered.where(self.versions.c.uuid == uuid) |
|
1089 |
if cluster is not None: |
|
1090 |
filtered = filtered.where(self.versions.c.cluster == cluster) |
|
1091 |
s = s.where(v.c.serial == filtered) |
|
1084 | 1092 |
s = s.where(n.c.node == v.c.node) |
1085 | 1093 |
|
1086 | 1094 |
r = self.conn.execute(s) |
Also available in: Unified diff