| | @@ -102,25 +102,10 @@ |
| 102 | 102 | p->content = *pBlob; |
| 103 | 103 | blob_zero(pBlob); |
| 104 | 104 | bag_insert(&contentCache.inCache, rid); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | | -#if 0 |
| 108 | | -/* |
| 109 | | -** Remove an entry from the content cache |
| 110 | | -*/ |
| 111 | | -void content_cache_remove(int rid){ |
| 112 | | - int i; |
| 113 | | - for(i=0; i<contentCache.n && contentCache.a[i].rid!=rid; i++){} |
| 114 | | - if( i>=contentCache.n ) return; |
| 115 | | - contentCache.szTotal -= blob_size(&contentCache.a[i].content); |
| 116 | | - blob_reset(&contentCache.a[i].content); |
| 117 | | - contentCache.n--; |
| 118 | | - contentCache.a[i] = contentCache.a[contentCache.n]; |
| 119 | | -} |
| 120 | | -#endif |
| 121 | | - |
| 122 | 107 | /* |
| 123 | 108 | ** Clear the content cache. |
| 124 | 109 | */ |
| 125 | 110 | void content_clear_cache(void){ |
| 126 | 111 | int i; |
| | @@ -280,11 +265,11 @@ |
| 280 | 265 | if( a==0 ) fossil_panic("out of memory"); |
| 281 | 266 | } |
| 282 | 267 | a[n] = nextRid; |
| 283 | 268 | } |
| 284 | 269 | mx = n; |
| 285 | | - rc = content_of_blob(a[n], pBlob); |
| 270 | + rc = content_get(a[n], pBlob); |
| 286 | 271 | n--; |
| 287 | 272 | while( rc && n>=0 ){ |
| 288 | 273 | rc = content_of_blob(a[n], &delta); |
| 289 | 274 | if( rc ){ |
| 290 | 275 | blob_delta_apply(pBlob, &delta, &next); |
| | @@ -299,85 +284,17 @@ |
| 299 | 284 | n--; |
| 300 | 285 | } |
| 301 | 286 | free(a); |
| 302 | 287 | if( !rc ) blob_reset(pBlob); |
| 303 | 288 | } |
| 304 | | - return rc; |
| 305 | | -} |
| 306 | | - |
| 307 | | -#if 0 |
| 308 | | -/* |
| 309 | | -** Extract the content for ID rid and put it into the |
| 310 | | -** uninitialized blob. Return 1 on success. If the record |
| 311 | | -** is a phantom, zero pBlob and return 0. |
| 312 | | -*/ |
| 313 | | -int old_content_get(int rid, Blob *pBlob){ |
| 314 | | - Blob src; |
| 315 | | - int srcid; |
| 316 | | - int rc = 0; |
| 317 | | - int i; |
| 318 | | - static Bag inProcess; |
| 319 | | - |
| 320 | | - assert( g.repositoryOpen ); |
| 321 | | - blob_zero(pBlob); |
| 322 | | - if( rid==0 ) return 0; |
| 323 | | - |
| 324 | | - /* Early out if we know the content is not available */ |
| 325 | | - if( bag_find(&contentCache.missing, rid) ){ |
| 326 | | - return 0; |
| 327 | | - } |
| 328 | | - |
| 329 | | - /* Look for the artifact in the cache first */ |
| 330 | | - for(i=0; i<contentCache.n; i++){ |
| 331 | | - if( contentCache.a[i].rid==rid ){ |
| 332 | | - blob_copy(pBlob, &contentCache.a[i].content); |
| 333 | | - contentCache.a[i].age = contentCache.nextAge++; |
| 334 | | - return 1; |
| 335 | | - } |
| 336 | | - } |
| 337 | | - |
| 338 | | - /* See if we need to apply a delta to find this artifact */ |
| 339 | | - srcid = findSrcid(rid); |
| 340 | | - if( srcid ){ |
| 341 | | - /* Yes, a delta is required */ |
| 342 | | - if( bag_find(&inProcess, srcid) ){ |
| 343 | | - db_multi_exec( |
| 344 | | - "UPDATE blob SET content=NULL, size=-1 WHERE rid=%d;" |
| 345 | | - "DELETE FROM delta WHERE rid=%d;" |
| 346 | | - "INSERT OR IGNORE INTO phantom VALUES(%d);", |
| 347 | | - srcid, srcid, srcid |
| 348 | | - ); |
| 349 | | - blob_zero(pBlob); |
| 350 | | - return 0; |
| 351 | | - } |
| 352 | | - bag_insert(&inProcess, srcid); |
| 353 | | - |
| 354 | | - cacheSrcid(rid); |
| 355 | | - if( content_get(srcid, &src) ){ |
| 356 | | - Blob delta; |
| 357 | | - if( content_of_blob(rid, &delta) ){ |
| 358 | | - blob_init(pBlob,0,0); |
| 359 | | - blob_delta_apply(&src, &delta, pBlob); |
| 360 | | - blob_reset(&delta); |
| 361 | | - rc = 1; |
| 362 | | - } |
| 363 | | - } |
| 364 | | - bag_remove(&inProcess, srcid); |
| 365 | | - }else{ |
| 366 | | - /* No delta required. Read content directly from the database */ |
| 367 | | - if( content_of_blob(rid, pBlob) ){ |
| 368 | | - rc = 1; |
| 369 | | - } |
| 370 | | - } |
| 371 | 289 | if( rc==0 ){ |
| 372 | 290 | bag_insert(&contentCache.missing, rid); |
| 373 | 291 | }else{ |
| 374 | 292 | bag_insert(&contentCache.available, rid); |
| 375 | 293 | } |
| 376 | 294 | return rc; |
| 377 | 295 | } |
| 378 | | -#endif |
| 379 | 296 | |
| 380 | 297 | /* |
| 381 | 298 | ** COMMAND: artifact |
| 382 | 299 | ** |
| 383 | 300 | ** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME? |
| 384 | 301 | |