mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-07-11 02:16:07 -04:00
Merge branch 'diffbot' of github.com:gigablast/open-source-search-engine into diffbot
This commit is contained in:
@ -722,6 +722,8 @@ bool gotResults ( void *state ) {
|
||||
// reserve 1.5MB now!
|
||||
if ( ! sb.reserve(1500000 ,"pgresbuf" ) ) // 128000) )
|
||||
return true;
|
||||
// just in case it is empty, make it null terminated
|
||||
sb.nullTerm();
|
||||
|
||||
SearchInput *si = &st->m_si;
|
||||
|
||||
@ -978,7 +980,7 @@ bool gotResults ( void *state ) {
|
||||
Query *qq2;
|
||||
bool firstIgnored;
|
||||
bool isAdmin = si->m_isAdmin;
|
||||
if ( si->m_format == FORMAT_XML ) isAdmin = false;
|
||||
if ( si->m_format != FORMAT_HTML ) isAdmin = false;
|
||||
|
||||
// otherwise, we had no error
|
||||
if ( numResults == 0 && si->m_format == FORMAT_HTML ) {
|
||||
@ -1509,6 +1511,9 @@ bool gotResults ( void *state ) {
|
||||
}
|
||||
|
||||
|
||||
if ( sb.length() == 0 )
|
||||
sb.pushChar('\n');
|
||||
|
||||
return sendReply ( st , sb.getBufStart() );
|
||||
}
|
||||
|
||||
@ -1819,6 +1824,7 @@ static int printResult ( SafeBuf &sb,
|
||||
char *json = mr->ptr_content;
|
||||
// only print header row once, so pass in that flag
|
||||
if ( ! st->m_printedHeaderRow ) {
|
||||
sb.reset();
|
||||
printCSVHeaderRow ( &sb , st );
|
||||
st->m_printedHeaderRow = true;
|
||||
}
|
||||
|
31
Parms.cpp
31
Parms.cpp
@ -272,6 +272,13 @@ bool CommandRestartColl ( char *rec , WaitEntry *we ) {
|
||||
if ( dataSize < 1 ) { char *xx=NULL;*xx=0; }
|
||||
collnum_t oldCollnum = atol(data);
|
||||
|
||||
if ( oldCollnum < 0 ||
|
||||
oldCollnum >= g_collectiondb.m_numRecs ||
|
||||
! g_collectiondb.m_recs[oldCollnum] ) {
|
||||
log("parms: invalid collnum %li to restart",(long)oldCollnum);
|
||||
return true;
|
||||
}
|
||||
|
||||
// this can block if tree is saving, it has to wait
|
||||
// for tree save to complete before removing old
|
||||
// collnum recs from tree
|
||||
@ -305,6 +312,13 @@ bool CommandResetColl ( char *rec , WaitEntry *we ) {
|
||||
if ( dataSize < 1 ) { char *xx=NULL;*xx=0; }
|
||||
collnum_t oldCollnum = atol(data);
|
||||
|
||||
if ( oldCollnum < 0 ||
|
||||
oldCollnum >= g_collectiondb.m_numRecs ||
|
||||
! g_collectiondb.m_recs[oldCollnum] ) {
|
||||
log("parms: invalid collnum %li to reset",(long)oldCollnum);
|
||||
return true;
|
||||
}
|
||||
|
||||
// this will not go through if tree is saving, it has to wait
|
||||
// for tree save to complete before removing old
|
||||
// collnum recs from tree. so return false in that case so caller
|
||||
@ -16916,8 +16930,21 @@ bool Parms::convertHttpRequestToParmList (HttpRequest *hr, SafeBuf *parmList,
|
||||
bool hasAddCrawl = hr->hasField("addCrawl");
|
||||
bool hasAddBulk = hr->hasField("addBulk");
|
||||
bool hasAddColl = hr->hasField("addColl");
|
||||
if ( ! cr && token && name && customCrawl &&
|
||||
! hasAddCrawl && ! hasAddBulk && ! hasAddColl ) {
|
||||
// sometimes they try to delete a collection that is not there so do
|
||||
// not apply this logic in that case!
|
||||
bool hasDelete = hr->hasField("delete");
|
||||
bool hasRestart = hr->hasField("restart");
|
||||
bool hasReset = hr->hasField("reset");
|
||||
if ( ! cr &&
|
||||
token &&
|
||||
name &&
|
||||
customCrawl &&
|
||||
! hasDelete &&
|
||||
! hasRestart &&
|
||||
! hasReset &&
|
||||
! hasAddCrawl &&
|
||||
! hasAddBulk &&
|
||||
! hasAddColl ) {
|
||||
// reserve a new collnum for adding this crawl
|
||||
parmCollnum = g_collectiondb.reserveCollNum();
|
||||
// must be there!
|
||||
|
Reference in New Issue
Block a user