Fossil SCM
On the /cachestat page, provide a link to the timeline check-in context for the origin of each item in the cache.
Commit
61c33f67b3b7d840cee8dc700924f4f6f3fc875e12049200c0b7cc72bda3602a
Parent
9d845ebb001e853…
1 file changed
+35
-1
+35
-1
| --- src/cache.c | ||
| +++ src/cache.c | ||
| @@ -365,10 +365,37 @@ | ||
| 365 | 365 | }else{ |
| 366 | 366 | fossil_fatal("Unknown subcommand \"%s\"." |
| 367 | 367 | " Should be one of: clear init list size status", zCmd); |
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | + | |
| 371 | +/* | |
| 372 | +** Given a cache key, find the check-in hash and return it as a separate | |
| 373 | +** string. The returned string is obtained from fossil_malloc() and must | |
| 374 | +** be freed by the caller. | |
| 375 | +** | |
| 376 | +** Return NULL if not found. | |
| 377 | +** | |
| 378 | +** The key is usually in a format like these: | |
| 379 | +** | |
| 380 | +** /tarball/HASH/NAME | |
| 381 | +** /zip/HASH/NAME | |
| 382 | +** /sqlar/HASH/NAME | |
| 383 | +*/ | |
| 384 | +static char *cache_hash_of_key(const char *zKey){ | |
| 385 | + int i; | |
| 386 | + if( zKey==0 ) return 0; | |
| 387 | + if( zKey[0]!='/' ) return 0; | |
| 388 | + zKey++; | |
| 389 | + while( zKey[0] && zKey[0]!='/' ) zKey++; | |
| 390 | + if( zKey[0]==0 ) return 0; | |
| 391 | + zKey++; | |
| 392 | + for(i=0; zKey[i] && zKey[i]!='/'; i++){} | |
| 393 | + if( !validate16(zKey, i) ) return 0; | |
| 394 | + return fossil_strndup(zKey, i); | |
| 395 | +} | |
| 396 | + | |
| 370 | 397 | |
| 371 | 398 | /* |
| 372 | 399 | ** WEBPAGE: cachestat |
| 373 | 400 | ** |
| 374 | 401 | ** Show information about the webpage cache. Requires Setup privilege. |
| @@ -395,14 +422,21 @@ | ||
| 395 | 422 | ); |
| 396 | 423 | if( pStmt ){ |
| 397 | 424 | @ <ol> |
| 398 | 425 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 399 | 426 | const unsigned char *zName = sqlite3_column_text(pStmt,0); |
| 427 | + char *zHash = cache_hash_of_key((const char*)zName); | |
| 400 | 428 | @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br /> |
| 401 | 429 | @ size: %,lld(sqlite3_column_int64(pStmt,1)) |
| 402 | 430 | @ hit-count: %d(sqlite3_column_int(pStmt,2)) |
| 403 | - @ last-access: %s(sqlite3_column_text(pStmt,3))</p></li> | |
| 431 | + @ last-access: %s(sqlite3_column_text(pStmt,3)) \ | |
| 432 | + if( zHash ){ | |
| 433 | + @ %z(href("%R/timeline?c=%S",zHash))check-in</a>\ | |
| 434 | + fossil_free(zHash); | |
| 435 | + } | |
| 436 | + @ </p></li> | |
| 437 | + | |
| 404 | 438 | } |
| 405 | 439 | sqlite3_finalize(pStmt); |
| 406 | 440 | @ </ol> |
| 407 | 441 | } |
| 408 | 442 | zDbName = cacheName(); |
| 409 | 443 |
| --- src/cache.c | |
| +++ src/cache.c | |
| @@ -365,10 +365,37 @@ | |
| 365 | }else{ |
| 366 | fossil_fatal("Unknown subcommand \"%s\"." |
| 367 | " Should be one of: clear init list size status", zCmd); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /* |
| 372 | ** WEBPAGE: cachestat |
| 373 | ** |
| 374 | ** Show information about the webpage cache. Requires Setup privilege. |
| @@ -395,14 +422,21 @@ | |
| 395 | ); |
| 396 | if( pStmt ){ |
| 397 | @ <ol> |
| 398 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 399 | const unsigned char *zName = sqlite3_column_text(pStmt,0); |
| 400 | @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br /> |
| 401 | @ size: %,lld(sqlite3_column_int64(pStmt,1)) |
| 402 | @ hit-count: %d(sqlite3_column_int(pStmt,2)) |
| 403 | @ last-access: %s(sqlite3_column_text(pStmt,3))</p></li> |
| 404 | } |
| 405 | sqlite3_finalize(pStmt); |
| 406 | @ </ol> |
| 407 | } |
| 408 | zDbName = cacheName(); |
| 409 |
| --- src/cache.c | |
| +++ src/cache.c | |
| @@ -365,10 +365,37 @@ | |
| 365 | }else{ |
| 366 | fossil_fatal("Unknown subcommand \"%s\"." |
| 367 | " Should be one of: clear init list size status", zCmd); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /* |
| 372 | ** Given a cache key, find the check-in hash and return it as a separate |
| 373 | ** string. The returned string is obtained from fossil_malloc() and must |
| 374 | ** be freed by the caller. |
| 375 | ** |
| 376 | ** Return NULL if not found. |
| 377 | ** |
| 378 | ** The key is usually in a format like these: |
| 379 | ** |
| 380 | ** /tarball/HASH/NAME |
| 381 | ** /zip/HASH/NAME |
| 382 | ** /sqlar/HASH/NAME |
| 383 | */ |
| 384 | static char *cache_hash_of_key(const char *zKey){ |
| 385 | int i; |
| 386 | if( zKey==0 ) return 0; |
| 387 | if( zKey[0]!='/' ) return 0; |
| 388 | zKey++; |
| 389 | while( zKey[0] && zKey[0]!='/' ) zKey++; |
| 390 | if( zKey[0]==0 ) return 0; |
| 391 | zKey++; |
| 392 | for(i=0; zKey[i] && zKey[i]!='/'; i++){} |
| 393 | if( !validate16(zKey, i) ) return 0; |
| 394 | return fossil_strndup(zKey, i); |
| 395 | } |
| 396 | |
| 397 | |
| 398 | /* |
| 399 | ** WEBPAGE: cachestat |
| 400 | ** |
| 401 | ** Show information about the webpage cache. Requires Setup privilege. |
| @@ -395,14 +422,21 @@ | |
| 422 | ); |
| 423 | if( pStmt ){ |
| 424 | @ <ol> |
| 425 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 426 | const unsigned char *zName = sqlite3_column_text(pStmt,0); |
| 427 | char *zHash = cache_hash_of_key((const char*)zName); |
| 428 | @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br /> |
| 429 | @ size: %,lld(sqlite3_column_int64(pStmt,1)) |
| 430 | @ hit-count: %d(sqlite3_column_int(pStmt,2)) |
| 431 | @ last-access: %s(sqlite3_column_text(pStmt,3)) \ |
| 432 | if( zHash ){ |
| 433 | @ %z(href("%R/timeline?c=%S",zHash))check-in</a>\ |
| 434 | fossil_free(zHash); |
| 435 | } |
| 436 | @ </p></li> |
| 437 | |
| 438 | } |
| 439 | sqlite3_finalize(pStmt); |
| 440 | @ </ol> |
| 441 | } |
| 442 | zDbName = cacheName(); |
| 443 |