Fossil SCM
Get the /clusterlist working for non-admin users, though omit sensitive information for non-admins. Show the compressed size of clusters on that page.
Commit
90764bd6561cdade234f68ce7a1344fa788371ee6f4f13aa86694470c1d3f736
Parent
72a218cecf7b9f8…
1 file changed
+30
-16
+30
-16
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -2168,22 +2168,23 @@ | ||
| 2168 | 2168 | |
| 2169 | 2169 | /* |
| 2170 | 2170 | ** WEBPAGE: clusterlist |
| 2171 | 2171 | ** |
| 2172 | 2172 | ** Show information about all cluster artifacts in the database. |
| 2173 | -** This page is accessible by administrators only. | |
| 2174 | 2173 | */ |
| 2175 | 2174 | void clusterlist_page(void){ |
| 2176 | 2175 | Stmt q; |
| 2177 | 2176 | int cnt = 1; |
| 2178 | 2177 | sqlite3_int64 szTotal = 0; |
| 2178 | + sqlite3_int64 szCTotal = 0; | |
| 2179 | 2179 | login_check_credentials(); |
| 2180 | - if( !g.perm.Admin ){ login_needed(g.anon.Admin); return; } | |
| 2180 | + if( !g.perm.Read ){ login_needed(g.anon.Read); return; } | |
| 2181 | 2181 | style_header("All Cluster Artifacts"); |
| 2182 | 2182 | db_prepare(&q, |
| 2183 | 2183 | "SELECT blob.uuid, " |
| 2184 | 2184 | " blob.size, " |
| 2185 | + " octet_length(blob.content), " | |
| 2185 | 2186 | " datetime(rcvfrom.mtime)," |
| 2186 | 2187 | " user.login," |
| 2187 | 2188 | " rcvfrom.ipaddr" |
| 2188 | 2189 | " FROM tagxref JOIN blob ON tagxref.rid=blob.rid" |
| 2189 | 2190 | " LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid" |
| @@ -2191,38 +2192,51 @@ | ||
| 2191 | 2192 | " WHERE tagxref.tagid=%d" |
| 2192 | 2193 | " ORDER BY rcvfrom.mtime, blob.uuid", |
| 2193 | 2194 | TAG_CLUSTER |
| 2194 | 2195 | ); |
| 2195 | 2196 | @ <table cellpadding="2" cellspacing="0" border="1"> |
| 2196 | - @ <tr><th> <th>Hash<th>Received<th>Size<th>User<th>IP-Address | |
| 2197 | + @ <tr><th> | |
| 2198 | + @ <th>Hash | |
| 2199 | + @ <th>Date Received | |
| 2200 | + @ <th>Size | |
| 2201 | + @ <th>Compressed Size | |
| 2202 | + if( g.perm.Admin ){ | |
| 2203 | + @ <th>User<th>IP-Address | |
| 2204 | + } | |
| 2197 | 2205 | while( db_step(&q)==SQLITE_ROW ){ |
| 2198 | 2206 | const char *zUuid = db_column_text(&q, 0); |
| 2199 | 2207 | sqlite3_int64 sz = db_column_int64(&q, 1); |
| 2200 | - const char *zDate = db_column_text(&q, 2); | |
| 2201 | - const char *zUser = db_column_text(&q, 3); | |
| 2202 | - const char *zIp = db_column_text(&q, 4); | |
| 2208 | + sqlite3_int64 szC = db_column_int64(&q, 2); | |
| 2209 | + const char *zDate = db_column_text(&q, 3); | |
| 2210 | + const char *zUser = db_column_text(&q, 4); | |
| 2211 | + const char *zIp = db_column_text(&q, 5); | |
| 2203 | 2212 | szTotal += sz; |
| 2213 | + szCTotal += szC; | |
| 2204 | 2214 | @ <tr><td align="right">%d(cnt++) |
| 2205 | 2215 | @ <td><a href="%R/info/%S(zUuid)">%S(zUuid)</a> |
| 2206 | 2216 | if( zDate ){ |
| 2207 | 2217 | @ <td>%h(zDate) |
| 2208 | 2218 | }else{ |
| 2209 | 2219 | @ <td> |
| 2210 | 2220 | } |
| 2211 | 2221 | @ <td align="right">%,lld(sz) |
| 2212 | - if( zUser ){ | |
| 2213 | - @ <td>%h(zUser) | |
| 2214 | - }else{ | |
| 2215 | - @ <td> | |
| 2216 | - } | |
| 2217 | - if( zIp ){ | |
| 2218 | - @ <td>%h(zIp) | |
| 2219 | - }else{ | |
| 2220 | - @ <td> | |
| 2222 | + @ <td align="right">%,lld(szC) | |
| 2223 | + if( g.perm.Admin ){ | |
| 2224 | + if( zUser ){ | |
| 2225 | + @ <td>%h(zUser) | |
| 2226 | + }else{ | |
| 2227 | + @ <td> | |
| 2228 | + } | |
| 2229 | + if( zIp ){ | |
| 2230 | + @ <td>%h(zIp) | |
| 2231 | + }else{ | |
| 2232 | + @ <td> | |
| 2233 | + } | |
| 2221 | 2234 | } |
| 2222 | 2235 | @ </tr> |
| 2223 | 2236 | } |
| 2224 | 2237 | @ </table> |
| 2225 | 2238 | db_finalize(&q); |
| 2226 | - @ <p>Total size of all clusters: %,lld(szTotal) bytes</p> | |
| 2239 | + @ <p>Total size of all clusters: %,lld(szTotal) bytes, | |
| 2240 | + @ %,lld(szCTotal) bytes compressed</p> | |
| 2227 | 2241 | style_finish_page(); |
| 2228 | 2242 | } |
| 2229 | 2243 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -2168,22 +2168,23 @@ | |
| 2168 | |
| 2169 | /* |
| 2170 | ** WEBPAGE: clusterlist |
| 2171 | ** |
| 2172 | ** Show information about all cluster artifacts in the database. |
| 2173 | ** This page is accessible by administrators only. |
| 2174 | */ |
| 2175 | void clusterlist_page(void){ |
| 2176 | Stmt q; |
| 2177 | int cnt = 1; |
| 2178 | sqlite3_int64 szTotal = 0; |
| 2179 | login_check_credentials(); |
| 2180 | if( !g.perm.Admin ){ login_needed(g.anon.Admin); return; } |
| 2181 | style_header("All Cluster Artifacts"); |
| 2182 | db_prepare(&q, |
| 2183 | "SELECT blob.uuid, " |
| 2184 | " blob.size, " |
| 2185 | " datetime(rcvfrom.mtime)," |
| 2186 | " user.login," |
| 2187 | " rcvfrom.ipaddr" |
| 2188 | " FROM tagxref JOIN blob ON tagxref.rid=blob.rid" |
| 2189 | " LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid" |
| @@ -2191,38 +2192,51 @@ | |
| 2191 | " WHERE tagxref.tagid=%d" |
| 2192 | " ORDER BY rcvfrom.mtime, blob.uuid", |
| 2193 | TAG_CLUSTER |
| 2194 | ); |
| 2195 | @ <table cellpadding="2" cellspacing="0" border="1"> |
| 2196 | @ <tr><th> <th>Hash<th>Received<th>Size<th>User<th>IP-Address |
| 2197 | while( db_step(&q)==SQLITE_ROW ){ |
| 2198 | const char *zUuid = db_column_text(&q, 0); |
| 2199 | sqlite3_int64 sz = db_column_int64(&q, 1); |
| 2200 | const char *zDate = db_column_text(&q, 2); |
| 2201 | const char *zUser = db_column_text(&q, 3); |
| 2202 | const char *zIp = db_column_text(&q, 4); |
| 2203 | szTotal += sz; |
| 2204 | @ <tr><td align="right">%d(cnt++) |
| 2205 | @ <td><a href="%R/info/%S(zUuid)">%S(zUuid)</a> |
| 2206 | if( zDate ){ |
| 2207 | @ <td>%h(zDate) |
| 2208 | }else{ |
| 2209 | @ <td> |
| 2210 | } |
| 2211 | @ <td align="right">%,lld(sz) |
| 2212 | if( zUser ){ |
| 2213 | @ <td>%h(zUser) |
| 2214 | }else{ |
| 2215 | @ <td> |
| 2216 | } |
| 2217 | if( zIp ){ |
| 2218 | @ <td>%h(zIp) |
| 2219 | }else{ |
| 2220 | @ <td> |
| 2221 | } |
| 2222 | @ </tr> |
| 2223 | } |
| 2224 | @ </table> |
| 2225 | db_finalize(&q); |
| 2226 | @ <p>Total size of all clusters: %,lld(szTotal) bytes</p> |
| 2227 | style_finish_page(); |
| 2228 | } |
| 2229 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -2168,22 +2168,23 @@ | |
| 2168 | |
| 2169 | /* |
| 2170 | ** WEBPAGE: clusterlist |
| 2171 | ** |
| 2172 | ** Show information about all cluster artifacts in the database. |
| 2173 | */ |
| 2174 | void clusterlist_page(void){ |
| 2175 | Stmt q; |
| 2176 | int cnt = 1; |
| 2177 | sqlite3_int64 szTotal = 0; |
| 2178 | sqlite3_int64 szCTotal = 0; |
| 2179 | login_check_credentials(); |
| 2180 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 2181 | style_header("All Cluster Artifacts"); |
| 2182 | db_prepare(&q, |
| 2183 | "SELECT blob.uuid, " |
| 2184 | " blob.size, " |
| 2185 | " octet_length(blob.content), " |
| 2186 | " datetime(rcvfrom.mtime)," |
| 2187 | " user.login," |
| 2188 | " rcvfrom.ipaddr" |
| 2189 | " FROM tagxref JOIN blob ON tagxref.rid=blob.rid" |
| 2190 | " LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid" |
| @@ -2191,38 +2192,51 @@ | |
| 2192 | " WHERE tagxref.tagid=%d" |
| 2193 | " ORDER BY rcvfrom.mtime, blob.uuid", |
| 2194 | TAG_CLUSTER |
| 2195 | ); |
| 2196 | @ <table cellpadding="2" cellspacing="0" border="1"> |
| 2197 | @ <tr><th> |
| 2198 | @ <th>Hash |
| 2199 | @ <th>Date Received |
| 2200 | @ <th>Size |
| 2201 | @ <th>Compressed Size |
| 2202 | if( g.perm.Admin ){ |
| 2203 | @ <th>User<th>IP-Address |
| 2204 | } |
| 2205 | while( db_step(&q)==SQLITE_ROW ){ |
| 2206 | const char *zUuid = db_column_text(&q, 0); |
| 2207 | sqlite3_int64 sz = db_column_int64(&q, 1); |
| 2208 | sqlite3_int64 szC = db_column_int64(&q, 2); |
| 2209 | const char *zDate = db_column_text(&q, 3); |
| 2210 | const char *zUser = db_column_text(&q, 4); |
| 2211 | const char *zIp = db_column_text(&q, 5); |
| 2212 | szTotal += sz; |
| 2213 | szCTotal += szC; |
| 2214 | @ <tr><td align="right">%d(cnt++) |
| 2215 | @ <td><a href="%R/info/%S(zUuid)">%S(zUuid)</a> |
| 2216 | if( zDate ){ |
| 2217 | @ <td>%h(zDate) |
| 2218 | }else{ |
| 2219 | @ <td> |
| 2220 | } |
| 2221 | @ <td align="right">%,lld(sz) |
| 2222 | @ <td align="right">%,lld(szC) |
| 2223 | if( g.perm.Admin ){ |
| 2224 | if( zUser ){ |
| 2225 | @ <td>%h(zUser) |
| 2226 | }else{ |
| 2227 | @ <td> |
| 2228 | } |
| 2229 | if( zIp ){ |
| 2230 | @ <td>%h(zIp) |
| 2231 | }else{ |
| 2232 | @ <td> |
| 2233 | } |
| 2234 | } |
| 2235 | @ </tr> |
| 2236 | } |
| 2237 | @ </table> |
| 2238 | db_finalize(&q); |
| 2239 | @ <p>Total size of all clusters: %,lld(szTotal) bytes, |
| 2240 | @ %,lld(szCTotal) bytes compressed</p> |
| 2241 | style_finish_page(); |
| 2242 | } |
| 2243 |