850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
|
return db_get("xfer-ticket-script", 0);
}
/*
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int xfer_run_script(const char *zScript, const char *zUuid){
int result;
if( !zScript ) return TH_OK;
Th_FossilInit(TH_INIT_DEFAULT);
if( zUuid ){
result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
if( result!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
return result;
}
}
result = Th_Eval(g.interp, 0, zScript, -1);
if( result!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
}
return result;
}
/*
** Runs the pre-transfer TH1 script, if any, and returns its return code.
** This script may be run multiple times. If the script performs actions
** that cannot be redone, it should use an internal [if] guard similar to
** the following:
|
|
|
|
|
|
|
|
|
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
|
return db_get("xfer-ticket-script", 0);
}
/*
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int xfer_run_script(const char *zScript, const char *zUuid){
int rc;
if( !zScript ) return TH_OK;
Th_FossilInit(TH_INIT_DEFAULT);
if( zUuid ){
rc = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
if( rc!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
return rc;
}
}
rc = Th_Eval(g.interp, 0, zScript, -1);
if( rc!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
}
return rc;
}
/*
** Runs the pre-transfer TH1 script, if any, and returns its return code.
** This script may be run multiple times. If the script performs actions
** that cannot be redone, it should use an internal [if] guard similar to
** the following:
|
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
|
Xfer xfer;
int deltaFlag = 0;
int isClone = 0;
int nGimme = 0;
int size;
int recvConfig = 0;
char *zNow;
int result;
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
fossil_redirect_home();
}
g.zLogin = "anonymous";
login_set_anon_nobody_capabilities();
login_check_credentials();
|
|
|
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
|
Xfer xfer;
int deltaFlag = 0;
int isClone = 0;
int nGimme = 0;
int size;
int recvConfig = 0;
char *zNow;
int rc;
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
fossil_redirect_home();
}
g.zLogin = "anonymous";
login_set_anon_nobody_capabilities();
login_check_credentials();
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
|
g.xferPanic = 1;
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
);
manifest_crosslink_begin();
result = xfer_run_common_script();
if( result==TH_ERROR ){
cgi_reset_content();
@ error common\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
while( blob_line(xfer.pIn, &xfer.line) ){
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
if( blob_size(&xfer.line)==0 ) continue;
|
|
|
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
|
g.xferPanic = 1;
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
);
manifest_crosslink_begin();
rc = xfer_run_common_script();
if( rc==TH_ERROR ){
cgi_reset_content();
@ error common\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
while( blob_line(xfer.pIn, &xfer.line) ){
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
if( blob_size(&xfer.line)==0 ) continue;
|
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
|
cgi_reset_content();
@ error bad\scommand:\s%F(blob_str(&xfer.line))
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
if( isPush ){
if( result==TH_OK ){
result = xfer_run_script(xfer_push_code(), 0);
if( result==TH_ERROR ){
cgi_reset_content();
@ error push\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
}
request_phantoms(&xfer, 500);
}
|
|
|
|
|
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
|
cgi_reset_content();
@ error bad\scommand:\s%F(blob_str(&xfer.line))
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
if( isPush ){
if( rc==TH_OK ){
rc = xfer_run_script(xfer_push_code(), 0);
if( rc==TH_ERROR ){
cgi_reset_content();
@ error push\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
}
request_phantoms(&xfer, 500);
}
|