Fossil SCM
Allow an alternative URL syntax for downloading artifacts via the <tt>/zip</tt> page. The original way is: <verbatim> http://localhost:8080/zip/fa6e9930177e84ce089b30ad768c454a012364f7.zip </verbatim> which will store the artifact in the file <tt>a6e9930177e84ce089b30ad768c454a012364f7.zip</tt>. Alternatively it is now possible to download the artifact in e.g. the file <tt>fossil.zip</tt> via the URL: <verbatim> http://localhost:8080/zip/fossil.zip?rid=fa6e9930177e84ce089b30ad768c454a012364f7 </verbatim>
Commit
417dd898ab0640f2472ebd248ac80e80f0ec6972
Parent
fa6e9930177e84c…
1 file changed
+7
-4
+7
-4
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -351,31 +351,34 @@ | ||
| 351 | 351 | ** Generate a ZIP archive for the baseline. |
| 352 | 352 | ** Return that ZIP archive as the HTTP reply content. |
| 353 | 353 | */ |
| 354 | 354 | void baseline_zip_page(void){ |
| 355 | 355 | int rid; |
| 356 | - char *zName; | |
| 357 | - int nName; | |
| 356 | + char *zName, *zRid; | |
| 357 | + int nName, nRid; | |
| 358 | 358 | Blob zip; |
| 359 | 359 | |
| 360 | 360 | login_check_credentials(); |
| 361 | 361 | if( !g.okZip && (!g.okRead || !g.okHistory) ){ login_needed(); return; } |
| 362 | 362 | zName = mprintf("%s", PD("name","")); |
| 363 | 363 | nName = strlen(zName); |
| 364 | + zRid = mprintf("%s", PD("rid","")); | |
| 365 | + nRid = strlen(zRid); | |
| 364 | 366 | for(nName=strlen(zName)-1; nName>5; nName--){ |
| 365 | 367 | if( zName[nName]=='.' ){ |
| 366 | 368 | zName[nName] = 0; |
| 367 | 369 | break; |
| 368 | 370 | } |
| 369 | 371 | } |
| 370 | - rid = name_to_rid(zName); | |
| 372 | + rid = name_to_rid(nRid?zRid:zName); | |
| 371 | 373 | if( rid==0 ){ |
| 372 | 374 | @ Not found |
| 373 | 375 | return; |
| 374 | 376 | } |
| 375 | - if( nName>10 ) zName[10] = 0; | |
| 377 | + if( nRid==0 && nName>10 ) zName[10] = 0; | |
| 376 | 378 | zip_of_baseline(rid, &zip, zName); |
| 377 | 379 | free( zName ); |
| 380 | + free( zRid ); | |
| 378 | 381 | cgi_set_content(&zip); |
| 379 | 382 | cgi_set_content_type("application/zip"); |
| 380 | 383 | cgi_reply(); |
| 381 | 384 | } |
| 382 | 385 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -351,31 +351,34 @@ | |
| 351 | ** Generate a ZIP archive for the baseline. |
| 352 | ** Return that ZIP archive as the HTTP reply content. |
| 353 | */ |
| 354 | void baseline_zip_page(void){ |
| 355 | int rid; |
| 356 | char *zName; |
| 357 | int nName; |
| 358 | Blob zip; |
| 359 | |
| 360 | login_check_credentials(); |
| 361 | if( !g.okZip && (!g.okRead || !g.okHistory) ){ login_needed(); return; } |
| 362 | zName = mprintf("%s", PD("name","")); |
| 363 | nName = strlen(zName); |
| 364 | for(nName=strlen(zName)-1; nName>5; nName--){ |
| 365 | if( zName[nName]=='.' ){ |
| 366 | zName[nName] = 0; |
| 367 | break; |
| 368 | } |
| 369 | } |
| 370 | rid = name_to_rid(zName); |
| 371 | if( rid==0 ){ |
| 372 | @ Not found |
| 373 | return; |
| 374 | } |
| 375 | if( nName>10 ) zName[10] = 0; |
| 376 | zip_of_baseline(rid, &zip, zName); |
| 377 | free( zName ); |
| 378 | cgi_set_content(&zip); |
| 379 | cgi_set_content_type("application/zip"); |
| 380 | cgi_reply(); |
| 381 | } |
| 382 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -351,31 +351,34 @@ | |
| 351 | ** Generate a ZIP archive for the baseline. |
| 352 | ** Return that ZIP archive as the HTTP reply content. |
| 353 | */ |
| 354 | void baseline_zip_page(void){ |
| 355 | int rid; |
| 356 | char *zName, *zRid; |
| 357 | int nName, nRid; |
| 358 | Blob zip; |
| 359 | |
| 360 | login_check_credentials(); |
| 361 | if( !g.okZip && (!g.okRead || !g.okHistory) ){ login_needed(); return; } |
| 362 | zName = mprintf("%s", PD("name","")); |
| 363 | nName = strlen(zName); |
| 364 | zRid = mprintf("%s", PD("rid","")); |
| 365 | nRid = strlen(zRid); |
| 366 | for(nName=strlen(zName)-1; nName>5; nName--){ |
| 367 | if( zName[nName]=='.' ){ |
| 368 | zName[nName] = 0; |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | rid = name_to_rid(nRid?zRid:zName); |
| 373 | if( rid==0 ){ |
| 374 | @ Not found |
| 375 | return; |
| 376 | } |
| 377 | if( nRid==0 && nName>10 ) zName[10] = 0; |
| 378 | zip_of_baseline(rid, &zip, zName); |
| 379 | free( zName ); |
| 380 | free( zRid ); |
| 381 | cgi_set_content(&zip); |
| 382 | cgi_set_content_type("application/zip"); |
| 383 | cgi_reply(); |
| 384 | } |
| 385 |