Fossil SCM
The common xfer script should only be run once for each interpreter.
Commit
55fe2bb814ae65848ed38a4c1e366d4729113b7f
Parent
7c24de9cf192df3…
2 files changed
+1
-4
+10
-14
+1
-4
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2037,14 +2037,11 @@ | ||
| 2037 | 2037 | ); |
| 2038 | 2038 | blob_reset(&comment); |
| 2039 | 2039 | } |
| 2040 | 2040 | db_end_transaction(0); |
| 2041 | 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | - result = (xfer_run_common_script()==TH_OK); | |
| 2043 | - if( result ){ | |
| 2044 | - result = (xfer_run_script(zScript, zUuid)==TH_OK); | |
| 2045 | - } | |
| 2042 | + result = (xfer_run_script(zScript, zUuid)==TH_OK); | |
| 2046 | 2043 | } |
| 2047 | 2044 | if( p->type==CFTYPE_MANIFEST ){ |
| 2048 | 2045 | manifest_cache_insert(p); |
| 2049 | 2046 | }else{ |
| 2050 | 2047 | manifest_destroy(p); |
| 2051 | 2048 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2037,14 +2037,11 @@ | |
| 2037 | ); |
| 2038 | blob_reset(&comment); |
| 2039 | } |
| 2040 | db_end_transaction(0); |
| 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | result = (xfer_run_common_script()==TH_OK); |
| 2043 | if( result ){ |
| 2044 | result = (xfer_run_script(zScript, zUuid)==TH_OK); |
| 2045 | } |
| 2046 | } |
| 2047 | if( p->type==CFTYPE_MANIFEST ){ |
| 2048 | manifest_cache_insert(p); |
| 2049 | }else{ |
| 2050 | manifest_destroy(p); |
| 2051 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2037,14 +2037,11 @@ | |
| 2037 | ); |
| 2038 | blob_reset(&comment); |
| 2039 | } |
| 2040 | db_end_transaction(0); |
| 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | result = (xfer_run_script(zScript, zUuid)==TH_OK); |
| 2043 | } |
| 2044 | if( p->type==CFTYPE_MANIFEST ){ |
| 2045 | manifest_cache_insert(p); |
| 2046 | }else{ |
| 2047 | manifest_destroy(p); |
| 2048 |
+10
-14
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -852,13 +852,22 @@ | ||
| 852 | 852 | |
| 853 | 853 | /* |
| 854 | 854 | ** Run the specified TH1 script, if any, and returns 1 on error. |
| 855 | 855 | */ |
| 856 | 856 | int xfer_run_script(const char *zScript, const char *zUuid){ |
| 857 | + static int commonScriptRan = 0; | |
| 857 | 858 | int result; |
| 859 | + if( !commonScriptRan ){ | |
| 860 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 861 | + result = Th_Eval(g.interp, 0, xfer_common_code(), -1); | |
| 862 | + if( result!=TH_OK ){ | |
| 863 | + fossil_error(1, "%s", Th_GetResult(g.interp, 0)); | |
| 864 | + return result; | |
| 865 | + } | |
| 866 | + commonScriptRan = 1; | |
| 867 | + } | |
| 858 | 868 | if( !zScript ) return TH_OK; |
| 859 | - Th_FossilInit(TH_INIT_DEFAULT); | |
| 860 | 869 | if( zUuid ){ |
| 861 | 870 | result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); |
| 862 | 871 | if( result!=TH_OK ){ |
| 863 | 872 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 864 | 873 | return result; |
| @@ -869,18 +878,10 @@ | ||
| 869 | 878 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 870 | 879 | } |
| 871 | 880 | return result; |
| 872 | 881 | } |
| 873 | 882 | |
| 874 | -/* | |
| 875 | -** Runs the pre-transfer TH1 script, if any, and returns its return code. | |
| 876 | -*/ | |
| 877 | -int xfer_run_common_script(void){ | |
| 878 | - Th_FossilInit(TH_INIT_DEFAULT); | |
| 879 | - return xfer_run_script(xfer_common_code(), 0); | |
| 880 | -} | |
| 881 | - | |
| 882 | 883 | /* |
| 883 | 884 | ** If this variable is set, disable login checks. Used for debugging |
| 884 | 885 | ** only. |
| 885 | 886 | */ |
| 886 | 887 | static int disableLogin = 0; |
| @@ -936,15 +937,10 @@ | ||
| 936 | 937 | db_begin_transaction(); |
| 937 | 938 | db_multi_exec( |
| 938 | 939 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 939 | 940 | ); |
| 940 | 941 | manifest_crosslink_begin(); |
| 941 | - if( xfer_run_common_script()!=TH_OK ){ | |
| 942 | - cgi_reset_content(); | |
| 943 | - @ error common\sscript\sfailed:\s%F(Th_GetResult(g.interp, 0)) | |
| 944 | - nErr++; | |
| 945 | - } | |
| 946 | 942 | while( blob_line(xfer.pIn, &xfer.line) ){ |
| 947 | 943 | if( blob_buffer(&xfer.line)[0]=='#' ) continue; |
| 948 | 944 | if( blob_size(&xfer.line)==0 ) continue; |
| 949 | 945 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 950 | 946 | |
| 951 | 947 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -852,13 +852,22 @@ | |
| 852 | |
| 853 | /* |
| 854 | ** Run the specified TH1 script, if any, and returns 1 on error. |
| 855 | */ |
| 856 | int xfer_run_script(const char *zScript, const char *zUuid){ |
| 857 | int result; |
| 858 | if( !zScript ) return TH_OK; |
| 859 | Th_FossilInit(TH_INIT_DEFAULT); |
| 860 | if( zUuid ){ |
| 861 | result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); |
| 862 | if( result!=TH_OK ){ |
| 863 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 864 | return result; |
| @@ -869,18 +878,10 @@ | |
| 869 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 870 | } |
| 871 | return result; |
| 872 | } |
| 873 | |
| 874 | /* |
| 875 | ** Runs the pre-transfer TH1 script, if any, and returns its return code. |
| 876 | */ |
| 877 | int xfer_run_common_script(void){ |
| 878 | Th_FossilInit(TH_INIT_DEFAULT); |
| 879 | return xfer_run_script(xfer_common_code(), 0); |
| 880 | } |
| 881 | |
| 882 | /* |
| 883 | ** If this variable is set, disable login checks. Used for debugging |
| 884 | ** only. |
| 885 | */ |
| 886 | static int disableLogin = 0; |
| @@ -936,15 +937,10 @@ | |
| 936 | db_begin_transaction(); |
| 937 | db_multi_exec( |
| 938 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 939 | ); |
| 940 | manifest_crosslink_begin(); |
| 941 | if( xfer_run_common_script()!=TH_OK ){ |
| 942 | cgi_reset_content(); |
| 943 | @ error common\sscript\sfailed:\s%F(Th_GetResult(g.interp, 0)) |
| 944 | nErr++; |
| 945 | } |
| 946 | while( blob_line(xfer.pIn, &xfer.line) ){ |
| 947 | if( blob_buffer(&xfer.line)[0]=='#' ) continue; |
| 948 | if( blob_size(&xfer.line)==0 ) continue; |
| 949 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 950 | |
| 951 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -852,13 +852,22 @@ | |
| 852 | |
| 853 | /* |
| 854 | ** Run the specified TH1 script, if any, and returns 1 on error. |
| 855 | */ |
| 856 | int xfer_run_script(const char *zScript, const char *zUuid){ |
| 857 | static int commonScriptRan = 0; |
| 858 | int result; |
| 859 | if( !commonScriptRan ){ |
| 860 | Th_FossilInit(TH_INIT_DEFAULT); |
| 861 | result = Th_Eval(g.interp, 0, xfer_common_code(), -1); |
| 862 | if( result!=TH_OK ){ |
| 863 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 864 | return result; |
| 865 | } |
| 866 | commonScriptRan = 1; |
| 867 | } |
| 868 | if( !zScript ) return TH_OK; |
| 869 | if( zUuid ){ |
| 870 | result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); |
| 871 | if( result!=TH_OK ){ |
| 872 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 873 | return result; |
| @@ -869,18 +878,10 @@ | |
| 878 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 879 | } |
| 880 | return result; |
| 881 | } |
| 882 | |
| 883 | /* |
| 884 | ** If this variable is set, disable login checks. Used for debugging |
| 885 | ** only. |
| 886 | */ |
| 887 | static int disableLogin = 0; |
| @@ -936,15 +937,10 @@ | |
| 937 | db_begin_transaction(); |
| 938 | db_multi_exec( |
| 939 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 940 | ); |
| 941 | manifest_crosslink_begin(); |
| 942 | while( blob_line(xfer.pIn, &xfer.line) ){ |
| 943 | if( blob_buffer(&xfer.line)[0]=='#' ) continue; |
| 944 | if( blob_size(&xfer.line)==0 ) continue; |
| 945 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 946 | |
| 947 |