Fossil SCM
The rebuild command corrects any errors seen in the blob.size field.
Commit
5b74febbccab50c65bb9d38a6192834927ebb8f9
Parent
81eb00def74419c…
1 file changed
+20
-3
+20
-3
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -50,10 +50,20 @@ | ||
| 50 | 50 | @ owner text, -- Owner of this report format (not used) |
| 51 | 51 | @ title text, -- Title of this report |
| 52 | 52 | @ cols text, -- A color-key specification |
| 53 | 53 | @ sqlcode text -- An SQL SELECT statement for this report |
| 54 | 54 | @ ); |
| 55 | +@ | |
| 56 | +@ -- A cache for mapping baseline artifact ID + filename into file | |
| 57 | +@ -- artifact ID. Used by the /doc method. | |
| 58 | +@ -- | |
| 59 | +@ CREATE TABLE IF NOT EXISTS vcache( | |
| 60 | +@ vid integer, -- Baseline artifact ID | |
| 61 | +@ fname text, -- Filename | |
| 62 | +@ rid integer, -- File artifact ID | |
| 63 | +@ UNIQUE(vid,fname,rid) | |
| 64 | +@ ); | |
| 55 | 65 | ; |
| 56 | 66 | |
| 57 | 67 | /* |
| 58 | 68 | ** Variables used for progress information |
| 59 | 69 | */ |
| @@ -75,16 +85,23 @@ | ||
| 75 | 85 | /* |
| 76 | 86 | ** Rebuild cross-referencing information for the artifact |
| 77 | 87 | ** rid with content pBase and all of its descendants. This |
| 78 | 88 | ** routine clears the content buffer before returning. |
| 79 | 89 | */ |
| 80 | -static void rebuild_step(int rid, Blob *pBase){ | |
| 90 | +static void rebuild_step(int rid, int size, Blob *pBase){ | |
| 81 | 91 | Stmt q1; |
| 82 | 92 | Bag children; |
| 83 | 93 | Blob copy; |
| 84 | 94 | Blob *pUse; |
| 85 | 95 | int nChild, i, cid; |
| 96 | + | |
| 97 | + /* Fix up the "blob.size" field if needed. */ | |
| 98 | + if( size!=blob_size(pBase) ){ | |
| 99 | + db_multi_exec( | |
| 100 | + "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid | |
| 101 | + ); | |
| 102 | + } | |
| 86 | 103 | |
| 87 | 104 | /* Find all children of artifact rid */ |
| 88 | 105 | db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 89 | 106 | bag_init(&children); |
| 90 | 107 | while( db_step(&q1)==SQLITE_ROW ){ |
| @@ -119,11 +136,11 @@ | ||
| 119 | 136 | db_ephemeral_blob(&q2, 0, &delta); |
| 120 | 137 | blob_uncompress(&delta, &delta); |
| 121 | 138 | blob_delta_apply(pUse, &delta, pUse); |
| 122 | 139 | blob_reset(&delta); |
| 123 | 140 | db_finalize(&q2); |
| 124 | - rebuild_step(cid, pUse); | |
| 141 | + rebuild_step(cid, sz, pUse); | |
| 125 | 142 | }else{ |
| 126 | 143 | db_finalize(&q2); |
| 127 | 144 | blob_reset(pUse); |
| 128 | 145 | } |
| 129 | 146 | } |
| @@ -181,11 +198,11 @@ | ||
| 181 | 198 | int rid = db_column_int(&s, 0); |
| 182 | 199 | int size = db_column_int(&s, 1); |
| 183 | 200 | if( size>=0 ){ |
| 184 | 201 | Blob content; |
| 185 | 202 | content_get(rid, &content); |
| 186 | - rebuild_step(rid, &content); | |
| 203 | + rebuild_step(rid, size, &content); | |
| 187 | 204 | }else{ |
| 188 | 205 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 189 | 206 | rebuild_step_done(); |
| 190 | 207 | } |
| 191 | 208 | } |
| 192 | 209 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -50,10 +50,20 @@ | |
| 50 | @ owner text, -- Owner of this report format (not used) |
| 51 | @ title text, -- Title of this report |
| 52 | @ cols text, -- A color-key specification |
| 53 | @ sqlcode text -- An SQL SELECT statement for this report |
| 54 | @ ); |
| 55 | ; |
| 56 | |
| 57 | /* |
| 58 | ** Variables used for progress information |
| 59 | */ |
| @@ -75,16 +85,23 @@ | |
| 75 | /* |
| 76 | ** Rebuild cross-referencing information for the artifact |
| 77 | ** rid with content pBase and all of its descendants. This |
| 78 | ** routine clears the content buffer before returning. |
| 79 | */ |
| 80 | static void rebuild_step(int rid, Blob *pBase){ |
| 81 | Stmt q1; |
| 82 | Bag children; |
| 83 | Blob copy; |
| 84 | Blob *pUse; |
| 85 | int nChild, i, cid; |
| 86 | |
| 87 | /* Find all children of artifact rid */ |
| 88 | db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 89 | bag_init(&children); |
| 90 | while( db_step(&q1)==SQLITE_ROW ){ |
| @@ -119,11 +136,11 @@ | |
| 119 | db_ephemeral_blob(&q2, 0, &delta); |
| 120 | blob_uncompress(&delta, &delta); |
| 121 | blob_delta_apply(pUse, &delta, pUse); |
| 122 | blob_reset(&delta); |
| 123 | db_finalize(&q2); |
| 124 | rebuild_step(cid, pUse); |
| 125 | }else{ |
| 126 | db_finalize(&q2); |
| 127 | blob_reset(pUse); |
| 128 | } |
| 129 | } |
| @@ -181,11 +198,11 @@ | |
| 181 | int rid = db_column_int(&s, 0); |
| 182 | int size = db_column_int(&s, 1); |
| 183 | if( size>=0 ){ |
| 184 | Blob content; |
| 185 | content_get(rid, &content); |
| 186 | rebuild_step(rid, &content); |
| 187 | }else{ |
| 188 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 189 | rebuild_step_done(); |
| 190 | } |
| 191 | } |
| 192 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -50,10 +50,20 @@ | |
| 50 | @ owner text, -- Owner of this report format (not used) |
| 51 | @ title text, -- Title of this report |
| 52 | @ cols text, -- A color-key specification |
| 53 | @ sqlcode text -- An SQL SELECT statement for this report |
| 54 | @ ); |
| 55 | @ |
| 56 | @ -- A cache for mapping baseline artifact ID + filename into file |
| 57 | @ -- artifact ID. Used by the /doc method. |
| 58 | @ -- |
| 59 | @ CREATE TABLE IF NOT EXISTS vcache( |
| 60 | @ vid integer, -- Baseline artifact ID |
| 61 | @ fname text, -- Filename |
| 62 | @ rid integer, -- File artifact ID |
| 63 | @ UNIQUE(vid,fname,rid) |
| 64 | @ ); |
| 65 | ; |
| 66 | |
| 67 | /* |
| 68 | ** Variables used for progress information |
| 69 | */ |
| @@ -75,16 +85,23 @@ | |
| 85 | /* |
| 86 | ** Rebuild cross-referencing information for the artifact |
| 87 | ** rid with content pBase and all of its descendants. This |
| 88 | ** routine clears the content buffer before returning. |
| 89 | */ |
| 90 | static void rebuild_step(int rid, int size, Blob *pBase){ |
| 91 | Stmt q1; |
| 92 | Bag children; |
| 93 | Blob copy; |
| 94 | Blob *pUse; |
| 95 | int nChild, i, cid; |
| 96 | |
| 97 | /* Fix up the "blob.size" field if needed. */ |
| 98 | if( size!=blob_size(pBase) ){ |
| 99 | db_multi_exec( |
| 100 | "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid |
| 101 | ); |
| 102 | } |
| 103 | |
| 104 | /* Find all children of artifact rid */ |
| 105 | db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 106 | bag_init(&children); |
| 107 | while( db_step(&q1)==SQLITE_ROW ){ |
| @@ -119,11 +136,11 @@ | |
| 136 | db_ephemeral_blob(&q2, 0, &delta); |
| 137 | blob_uncompress(&delta, &delta); |
| 138 | blob_delta_apply(pUse, &delta, pUse); |
| 139 | blob_reset(&delta); |
| 140 | db_finalize(&q2); |
| 141 | rebuild_step(cid, sz, pUse); |
| 142 | }else{ |
| 143 | db_finalize(&q2); |
| 144 | blob_reset(pUse); |
| 145 | } |
| 146 | } |
| @@ -181,11 +198,11 @@ | |
| 198 | int rid = db_column_int(&s, 0); |
| 199 | int size = db_column_int(&s, 1); |
| 200 | if( size>=0 ){ |
| 201 | Blob content; |
| 202 | content_get(rid, &content); |
| 203 | rebuild_step(rid, size, &content); |
| 204 | }else{ |
| 205 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 206 | rebuild_step_done(); |
| 207 | } |
| 208 | } |
| 209 |