Fossil SCM
Add the /sqlar webpage. Link to this page from the /info page.
Commit
768e19219f86937b0b8af3289639798142557c63187232c75831359c28f39151
Parent
7eb5b0a2ae297c2…
2 files changed
+2
-2
+37
-14
+2
-2
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -756,12 +756,12 @@ | ||
| 756 | 756 | char *zUrl = mprintf("%R/tarball/%t-%S.tar.gz?uuid=%s", |
| 757 | 757 | zPJ, zUuid, zUuid); |
| 758 | 758 | @ </td></tr> |
| 759 | 759 | @ <tr><th>Downloads:</th><td> |
| 760 | 760 | @ %z(href("%s",zUrl))Tarball</a> |
| 761 | - @ | %z(href("%R/zip/%t-%S.zip?uuid=%!S",zPJ,zUuid,zUuid)) | |
| 762 | - @ ZIP archive</a> | |
| 761 | + @ | %z(href("%R/zip/%t-%S.zip?uuid=%!S",zPJ,zUuid,zUuid))ZIP archive</a> | |
| 762 | + @ | %z(href("%R/sqlar/%t-%S.sqlar?uuid=%!S",zPJ,zUuid,zUuid))SQL archive</a> | |
| 763 | 763 | fossil_free(zUrl); |
| 764 | 764 | } |
| 765 | 765 | @ </td></tr> |
| 766 | 766 | @ <tr><th>Other Links:</th> |
| 767 | 767 | @ <td> |
| 768 | 768 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -756,12 +756,12 @@ | |
| 756 | char *zUrl = mprintf("%R/tarball/%t-%S.tar.gz?uuid=%s", |
| 757 | zPJ, zUuid, zUuid); |
| 758 | @ </td></tr> |
| 759 | @ <tr><th>Downloads:</th><td> |
| 760 | @ %z(href("%s",zUrl))Tarball</a> |
| 761 | @ | %z(href("%R/zip/%t-%S.zip?uuid=%!S",zPJ,zUuid,zUuid)) |
| 762 | @ ZIP archive</a> |
| 763 | fossil_free(zUrl); |
| 764 | } |
| 765 | @ </td></tr> |
| 766 | @ <tr><th>Other Links:</th> |
| 767 | @ <td> |
| 768 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -756,12 +756,12 @@ | |
| 756 | char *zUrl = mprintf("%R/tarball/%t-%S.tar.gz?uuid=%s", |
| 757 | zPJ, zUuid, zUuid); |
| 758 | @ </td></tr> |
| 759 | @ <tr><th>Downloads:</th><td> |
| 760 | @ %z(href("%s",zUrl))Tarball</a> |
| 761 | @ | %z(href("%R/zip/%t-%S.zip?uuid=%!S",zPJ,zUuid,zUuid))ZIP archive</a> |
| 762 | @ | %z(href("%R/sqlar/%t-%S.sqlar?uuid=%!S",zPJ,zUuid,zUuid))SQL archive</a> |
| 763 | fossil_free(zUrl); |
| 764 | } |
| 765 | @ </td></tr> |
| 766 | @ <tr><th>Other Links:</th> |
| 767 | @ <td> |
| 768 |
+37
-14
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -825,19 +825,19 @@ | ||
| 825 | 825 | void sqlar_cmd(void){ |
| 826 | 826 | archive_cmd(ARCHIVE_SQLAR); |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | /* |
| 830 | +** WEBPAGE: sqlar | |
| 830 | 831 | ** WEBPAGE: zip |
| 831 | -** URL: /zip | |
| 832 | 832 | ** |
| 833 | -** Generate a ZIP archive for the check-in specified by the "r" | |
| 834 | -** query parameter. Return that ZIP archive as the HTTP reply content. | |
| 833 | +** Generate a ZIP or SQL archive for the check-in specified by the "r" | |
| 834 | +** query parameter. Return the archive as the HTTP reply content. | |
| 835 | 835 | ** |
| 836 | 836 | ** Query parameters: |
| 837 | 837 | ** |
| 838 | -** name=NAME[.zip] The base name of the output file. The default | |
| 838 | +** name=NAME The base name of the output file. The default | |
| 839 | 839 | ** value is a configuration parameter in the project |
| 840 | 840 | ** settings. A prefix of the name, omitting the |
| 841 | 841 | ** extension, is used as the top-most directory name. |
| 842 | 842 | ** |
| 843 | 843 | ** r=TAG The check-in that is turned into a ZIP archive. |
| @@ -864,13 +864,22 @@ | ||
| 864 | 864 | const char *zExclude; /* The ex= query parameter */ |
| 865 | 865 | Blob cacheKey; /* The key to cache */ |
| 866 | 866 | Glob *pInclude = 0; /* The compiled in= glob pattern */ |
| 867 | 867 | Glob *pExclude = 0; /* The compiled ex= glob pattern */ |
| 868 | 868 | Blob zip; /* ZIP archive accumulated here */ |
| 869 | + int eType = ARCHIVE_ZIP; /* Type of archive to generate */ | |
| 870 | + char *zType; /* Human-readable archive type */ | |
| 869 | 871 | |
| 870 | 872 | login_check_credentials(); |
| 871 | 873 | if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; } |
| 874 | + if( fossil_strcmp(g.zPath, "sqlar")==0 ){ | |
| 875 | + eType = ARCHIVE_SQLAR; | |
| 876 | + zType = "SQL"; | |
| 877 | + }else{ | |
| 878 | + eType = ARCHIVE_ZIP; | |
| 879 | + zType = "ZIP"; | |
| 880 | + } | |
| 872 | 881 | load_control(); |
| 873 | 882 | zName = mprintf("%s", PD("name","")); |
| 874 | 883 | nName = strlen(zName); |
| 875 | 884 | z = P("r"); |
| 876 | 885 | if( z==0 ) z = P("uuid"); |
| @@ -879,16 +888,26 @@ | ||
| 879 | 888 | nRid = strlen(zRid); |
| 880 | 889 | zInclude = P("in"); |
| 881 | 890 | if( zInclude ) pInclude = glob_create(zInclude); |
| 882 | 891 | zExclude = P("ex"); |
| 883 | 892 | if( zExclude ) pExclude = glob_create(zExclude); |
| 884 | - if( nName>4 && fossil_strcmp(&zName[nName-4], ".zip")==0 ){ | |
| 893 | + if( eType==ARCHIVE_ZIP | |
| 894 | + && nName>4 | |
| 895 | + && fossil_strcmp(&zName[nName-4], ".zip")==0 | |
| 896 | + ){ | |
| 885 | 897 | /* Special case: Remove the ".zip" suffix. */ |
| 886 | 898 | nName -= 4; |
| 887 | 899 | zName[nName] = 0; |
| 900 | + }else if( eType==ARCHIVE_SQLAR | |
| 901 | + && nName>6 | |
| 902 | + && fossil_strcmp(&zName[nName-6], ".sqlar")==0 | |
| 903 | + ){ | |
| 904 | + /* Special case: Remove the ".sqlar" suffix. */ | |
| 905 | + nName -= 6; | |
| 906 | + zName[nName] = 0; | |
| 888 | 907 | }else{ |
| 889 | - /* If the file suffix is not ".zip" then just remove the | |
| 908 | + /* If the file suffix is not ".zip" or ".sqlar" then just remove the | |
| 890 | 909 | ** suffix up to and including the last "." */ |
| 891 | 910 | for(nName=strlen(zName)-1; nName>5; nName--){ |
| 892 | 911 | if( zName[nName]=='.' ){ |
| 893 | 912 | zName[nName] = 0; |
| 894 | 913 | break; |
| @@ -903,18 +922,18 @@ | ||
| 903 | 922 | } |
| 904 | 923 | if( nRid==0 && nName>10 ) zName[10] = 0; |
| 905 | 924 | |
| 906 | 925 | /* Compute a unique key for the cache entry based on query parameters */ |
| 907 | 926 | blob_init(&cacheKey, 0, 0); |
| 908 | - blob_appendf(&cacheKey, "/zip/%z", rid_to_uuid(rid)); | |
| 927 | + blob_appendf(&cacheKey, "/%s/%z", g.zPath, rid_to_uuid(rid)); | |
| 909 | 928 | blob_appendf(&cacheKey, "/%q", zName); |
| 910 | 929 | if( zInclude ) blob_appendf(&cacheKey, ",in=%Q", zInclude); |
| 911 | 930 | if( zExclude ) blob_appendf(&cacheKey, ",ex=%Q", zExclude); |
| 912 | 931 | zKey = blob_str(&cacheKey); |
| 913 | 932 | |
| 914 | 933 | if( P("debug")!=0 ){ |
| 915 | - style_header("ZIP Archive Generator Debug Screen"); | |
| 934 | + style_header("%s Archive Generator Debug Screen", zType); | |
| 916 | 935 | @ zName = "%h(zName)"<br /> |
| 917 | 936 | @ rid = %d(rid)<br /> |
| 918 | 937 | if( zInclude ){ |
| 919 | 938 | @ zInclude = "%h(zInclude)"<br /> |
| 920 | 939 | } |
| @@ -924,28 +943,32 @@ | ||
| 924 | 943 | @ zKey = "%h(zKey)" |
| 925 | 944 | style_footer(); |
| 926 | 945 | return; |
| 927 | 946 | } |
| 928 | 947 | if( referred_from_login() ){ |
| 929 | - style_header("ZIP Archive Download"); | |
| 930 | - @ <form action='%R/zip/%h(zName).zip'> | |
| 948 | + style_header("%s Archive Download", zType); | |
| 949 | + @ <form action='%R/%s(g.zPath)/%h(zName).%s(g.zPath)'> | |
| 931 | 950 | cgi_query_parameters_to_hidden(); |
| 932 | - @ <p>ZIP Archive named <b>%h(zName).zip</b> holding the content | |
| 933 | - @ of check-in <b>%h(zRid)</b>: | |
| 951 | + @ <p>%s(zType) Archive named <b>%h(zName).%s(g.zPath)</b> | |
| 952 | + @ holding the content of check-in <b>%h(zRid)</b>: | |
| 934 | 953 | @ <input type="submit" value="Download" /> |
| 935 | 954 | @ </form> |
| 936 | 955 | style_footer(); |
| 937 | 956 | return; |
| 938 | 957 | } |
| 939 | 958 | blob_zero(&zip); |
| 940 | 959 | if( cache_read(&zip, zKey)==0 ){ |
| 941 | - zip_of_checkin(ARCHIVE_ZIP, rid, &zip, zName, pInclude, pExclude); | |
| 960 | + zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude); | |
| 942 | 961 | cache_write(&zip, zKey); |
| 943 | 962 | } |
| 944 | 963 | glob_free(pInclude); |
| 945 | 964 | glob_free(pExclude); |
| 946 | 965 | fossil_free(zName); |
| 947 | 966 | fossil_free(zRid); |
| 948 | 967 | blob_reset(&cacheKey); |
| 949 | 968 | cgi_set_content(&zip); |
| 950 | - cgi_set_content_type("application/zip"); | |
| 969 | + if( eType==ARCHIVE_ZIP ){ | |
| 970 | + cgi_set_content_type("application/zip"); | |
| 971 | + }else{ | |
| 972 | + cgi_set_content_type("application/sqlar"); | |
| 973 | + } | |
| 951 | 974 | } |
| 952 | 975 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -825,19 +825,19 @@ | |
| 825 | void sqlar_cmd(void){ |
| 826 | archive_cmd(ARCHIVE_SQLAR); |
| 827 | } |
| 828 | |
| 829 | /* |
| 830 | ** WEBPAGE: zip |
| 831 | ** URL: /zip |
| 832 | ** |
| 833 | ** Generate a ZIP archive for the check-in specified by the "r" |
| 834 | ** query parameter. Return that ZIP archive as the HTTP reply content. |
| 835 | ** |
| 836 | ** Query parameters: |
| 837 | ** |
| 838 | ** name=NAME[.zip] The base name of the output file. The default |
| 839 | ** value is a configuration parameter in the project |
| 840 | ** settings. A prefix of the name, omitting the |
| 841 | ** extension, is used as the top-most directory name. |
| 842 | ** |
| 843 | ** r=TAG The check-in that is turned into a ZIP archive. |
| @@ -864,13 +864,22 @@ | |
| 864 | const char *zExclude; /* The ex= query parameter */ |
| 865 | Blob cacheKey; /* The key to cache */ |
| 866 | Glob *pInclude = 0; /* The compiled in= glob pattern */ |
| 867 | Glob *pExclude = 0; /* The compiled ex= glob pattern */ |
| 868 | Blob zip; /* ZIP archive accumulated here */ |
| 869 | |
| 870 | login_check_credentials(); |
| 871 | if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; } |
| 872 | load_control(); |
| 873 | zName = mprintf("%s", PD("name","")); |
| 874 | nName = strlen(zName); |
| 875 | z = P("r"); |
| 876 | if( z==0 ) z = P("uuid"); |
| @@ -879,16 +888,26 @@ | |
| 879 | nRid = strlen(zRid); |
| 880 | zInclude = P("in"); |
| 881 | if( zInclude ) pInclude = glob_create(zInclude); |
| 882 | zExclude = P("ex"); |
| 883 | if( zExclude ) pExclude = glob_create(zExclude); |
| 884 | if( nName>4 && fossil_strcmp(&zName[nName-4], ".zip")==0 ){ |
| 885 | /* Special case: Remove the ".zip" suffix. */ |
| 886 | nName -= 4; |
| 887 | zName[nName] = 0; |
| 888 | }else{ |
| 889 | /* If the file suffix is not ".zip" then just remove the |
| 890 | ** suffix up to and including the last "." */ |
| 891 | for(nName=strlen(zName)-1; nName>5; nName--){ |
| 892 | if( zName[nName]=='.' ){ |
| 893 | zName[nName] = 0; |
| 894 | break; |
| @@ -903,18 +922,18 @@ | |
| 903 | } |
| 904 | if( nRid==0 && nName>10 ) zName[10] = 0; |
| 905 | |
| 906 | /* Compute a unique key for the cache entry based on query parameters */ |
| 907 | blob_init(&cacheKey, 0, 0); |
| 908 | blob_appendf(&cacheKey, "/zip/%z", rid_to_uuid(rid)); |
| 909 | blob_appendf(&cacheKey, "/%q", zName); |
| 910 | if( zInclude ) blob_appendf(&cacheKey, ",in=%Q", zInclude); |
| 911 | if( zExclude ) blob_appendf(&cacheKey, ",ex=%Q", zExclude); |
| 912 | zKey = blob_str(&cacheKey); |
| 913 | |
| 914 | if( P("debug")!=0 ){ |
| 915 | style_header("ZIP Archive Generator Debug Screen"); |
| 916 | @ zName = "%h(zName)"<br /> |
| 917 | @ rid = %d(rid)<br /> |
| 918 | if( zInclude ){ |
| 919 | @ zInclude = "%h(zInclude)"<br /> |
| 920 | } |
| @@ -924,28 +943,32 @@ | |
| 924 | @ zKey = "%h(zKey)" |
| 925 | style_footer(); |
| 926 | return; |
| 927 | } |
| 928 | if( referred_from_login() ){ |
| 929 | style_header("ZIP Archive Download"); |
| 930 | @ <form action='%R/zip/%h(zName).zip'> |
| 931 | cgi_query_parameters_to_hidden(); |
| 932 | @ <p>ZIP Archive named <b>%h(zName).zip</b> holding the content |
| 933 | @ of check-in <b>%h(zRid)</b>: |
| 934 | @ <input type="submit" value="Download" /> |
| 935 | @ </form> |
| 936 | style_footer(); |
| 937 | return; |
| 938 | } |
| 939 | blob_zero(&zip); |
| 940 | if( cache_read(&zip, zKey)==0 ){ |
| 941 | zip_of_checkin(ARCHIVE_ZIP, rid, &zip, zName, pInclude, pExclude); |
| 942 | cache_write(&zip, zKey); |
| 943 | } |
| 944 | glob_free(pInclude); |
| 945 | glob_free(pExclude); |
| 946 | fossil_free(zName); |
| 947 | fossil_free(zRid); |
| 948 | blob_reset(&cacheKey); |
| 949 | cgi_set_content(&zip); |
| 950 | cgi_set_content_type("application/zip"); |
| 951 | } |
| 952 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -825,19 +825,19 @@ | |
| 825 | void sqlar_cmd(void){ |
| 826 | archive_cmd(ARCHIVE_SQLAR); |
| 827 | } |
| 828 | |
| 829 | /* |
| 830 | ** WEBPAGE: sqlar |
| 831 | ** WEBPAGE: zip |
| 832 | ** |
| 833 | ** Generate a ZIP or SQL archive for the check-in specified by the "r" |
| 834 | ** query parameter. Return the archive as the HTTP reply content. |
| 835 | ** |
| 836 | ** Query parameters: |
| 837 | ** |
| 838 | ** name=NAME The base name of the output file. The default |
| 839 | ** value is a configuration parameter in the project |
| 840 | ** settings. A prefix of the name, omitting the |
| 841 | ** extension, is used as the top-most directory name. |
| 842 | ** |
| 843 | ** r=TAG The check-in that is turned into a ZIP archive. |
| @@ -864,13 +864,22 @@ | |
| 864 | const char *zExclude; /* The ex= query parameter */ |
| 865 | Blob cacheKey; /* The key to cache */ |
| 866 | Glob *pInclude = 0; /* The compiled in= glob pattern */ |
| 867 | Glob *pExclude = 0; /* The compiled ex= glob pattern */ |
| 868 | Blob zip; /* ZIP archive accumulated here */ |
| 869 | int eType = ARCHIVE_ZIP; /* Type of archive to generate */ |
| 870 | char *zType; /* Human-readable archive type */ |
| 871 | |
| 872 | login_check_credentials(); |
| 873 | if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; } |
| 874 | if( fossil_strcmp(g.zPath, "sqlar")==0 ){ |
| 875 | eType = ARCHIVE_SQLAR; |
| 876 | zType = "SQL"; |
| 877 | }else{ |
| 878 | eType = ARCHIVE_ZIP; |
| 879 | zType = "ZIP"; |
| 880 | } |
| 881 | load_control(); |
| 882 | zName = mprintf("%s", PD("name","")); |
| 883 | nName = strlen(zName); |
| 884 | z = P("r"); |
| 885 | if( z==0 ) z = P("uuid"); |
| @@ -879,16 +888,26 @@ | |
| 888 | nRid = strlen(zRid); |
| 889 | zInclude = P("in"); |
| 890 | if( zInclude ) pInclude = glob_create(zInclude); |
| 891 | zExclude = P("ex"); |
| 892 | if( zExclude ) pExclude = glob_create(zExclude); |
| 893 | if( eType==ARCHIVE_ZIP |
| 894 | && nName>4 |
| 895 | && fossil_strcmp(&zName[nName-4], ".zip")==0 |
| 896 | ){ |
| 897 | /* Special case: Remove the ".zip" suffix. */ |
| 898 | nName -= 4; |
| 899 | zName[nName] = 0; |
| 900 | }else if( eType==ARCHIVE_SQLAR |
| 901 | && nName>6 |
| 902 | && fossil_strcmp(&zName[nName-6], ".sqlar")==0 |
| 903 | ){ |
| 904 | /* Special case: Remove the ".sqlar" suffix. */ |
| 905 | nName -= 6; |
| 906 | zName[nName] = 0; |
| 907 | }else{ |
| 908 | /* If the file suffix is not ".zip" or ".sqlar" then just remove the |
| 909 | ** suffix up to and including the last "." */ |
| 910 | for(nName=strlen(zName)-1; nName>5; nName--){ |
| 911 | if( zName[nName]=='.' ){ |
| 912 | zName[nName] = 0; |
| 913 | break; |
| @@ -903,18 +922,18 @@ | |
| 922 | } |
| 923 | if( nRid==0 && nName>10 ) zName[10] = 0; |
| 924 | |
| 925 | /* Compute a unique key for the cache entry based on query parameters */ |
| 926 | blob_init(&cacheKey, 0, 0); |
| 927 | blob_appendf(&cacheKey, "/%s/%z", g.zPath, rid_to_uuid(rid)); |
| 928 | blob_appendf(&cacheKey, "/%q", zName); |
| 929 | if( zInclude ) blob_appendf(&cacheKey, ",in=%Q", zInclude); |
| 930 | if( zExclude ) blob_appendf(&cacheKey, ",ex=%Q", zExclude); |
| 931 | zKey = blob_str(&cacheKey); |
| 932 | |
| 933 | if( P("debug")!=0 ){ |
| 934 | style_header("%s Archive Generator Debug Screen", zType); |
| 935 | @ zName = "%h(zName)"<br /> |
| 936 | @ rid = %d(rid)<br /> |
| 937 | if( zInclude ){ |
| 938 | @ zInclude = "%h(zInclude)"<br /> |
| 939 | } |
| @@ -924,28 +943,32 @@ | |
| 943 | @ zKey = "%h(zKey)" |
| 944 | style_footer(); |
| 945 | return; |
| 946 | } |
| 947 | if( referred_from_login() ){ |
| 948 | style_header("%s Archive Download", zType); |
| 949 | @ <form action='%R/%s(g.zPath)/%h(zName).%s(g.zPath)'> |
| 950 | cgi_query_parameters_to_hidden(); |
| 951 | @ <p>%s(zType) Archive named <b>%h(zName).%s(g.zPath)</b> |
| 952 | @ holding the content of check-in <b>%h(zRid)</b>: |
| 953 | @ <input type="submit" value="Download" /> |
| 954 | @ </form> |
| 955 | style_footer(); |
| 956 | return; |
| 957 | } |
| 958 | blob_zero(&zip); |
| 959 | if( cache_read(&zip, zKey)==0 ){ |
| 960 | zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude); |
| 961 | cache_write(&zip, zKey); |
| 962 | } |
| 963 | glob_free(pInclude); |
| 964 | glob_free(pExclude); |
| 965 | fossil_free(zName); |
| 966 | fossil_free(zRid); |
| 967 | blob_reset(&cacheKey); |
| 968 | cgi_set_content(&zip); |
| 969 | if( eType==ARCHIVE_ZIP ){ |
| 970 | cgi_set_content_type("application/zip"); |
| 971 | }else{ |
| 972 | cgi_set_content_type("application/sqlar"); |
| 973 | } |
| 974 | } |
| 975 |