Changeset 1457 for trunk


Ignore:
Timestamp:
2000-08-27T23:09:14+12:00 (24 years ago)
Author:
stefan
Message:

Lots more changes to collectoraction. Nearly there now... hopefully

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r1449 r1457  
    4545  recpt = NULL;
    4646  do_mkcol = false;
    47   clone_failed = false;
    4847
    4948  cgiarginfo arg_ainfo;
     
    6160  arg_ainfo.defaultstatus = cgiarginfo::weak;
    6261  arg_ainfo.argdefault = "intro";
     62  arg_ainfo.savedarginfo = cgiarginfo::must;
     63  argsinfo.addarginfo (NULL, arg_ainfo);
     64
     65  // temporary directory name for this collector
     66  // session
     67  arg_ainfo.shortname = "bc1tmp";
     68  arg_ainfo.longname = "collector specific";
     69  arg_ainfo.multiplechar = true;
     70  arg_ainfo.defaultstatus = cgiarginfo::weak;
     71  arg_ainfo.argdefault = "";
    6372  arg_ainfo.savedarginfo = cgiarginfo::must;
    6473  argsinfo.addarginfo (NULL, arg_ainfo);
     
    245254    args["ug"] = "colbuilder";
    246255  }
     256 
     257  if (current_page == "new" || current_page == "existing") {
     258
     259    // assign (and create) a temporary directory
     260    assign_tmpname (args, logout);
     261
     262    // clean up any old builds left laying about in the tmp directory
     263    // (note that it's possible this could take some time if there's a huge
     264    // partially built collection laying about -- may need to think about doing
     265    // this in the background).
     266    text_t cleantmp_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "cleantmp.pl");
     267    char *cleantmp_cmdc = cleantmp_cmd.getcstr();
     268    system (cleantmp_cmdc);
     269    delete cleantmp_cmdc;
     270  }
    247271
    248272  if (args["bc1infochanged"] == "1") {
    249 
     273   
    250274    if (args["bc1dirname"].empty()) {
    251275      // we've just come from the "collection information" page for the
     
    255279      // the compressedoptions macros are set.
    256280      args["bc1dirname"] = get_directory_name (args["bc1fullname"]);
    257       do_mkcol = true;
    258     } else {
    259       // "collection information" has been changed after collection was made
     281
     282      text_t createfile = filename_cat (gsdlhome, "tmp", args["bc1tmp"], ".create");
     283      if (!file_exists (createfile)) {
     284    // we could do the mkcol.pl here but I guess it's nicer to do it in do_action()
     285    do_mkcol = true;
     286      } else {
     287    // .create file already exists but bc1dirname wasn't set ... this should only be
     288    // able to occur when the "reload" (and possibly the "back" and "forward" buttons)
     289    // have been used to get us here.
     290    // we'll check that the bc1dirname directory exists (in case of the unlikely
     291    // possibility that get_directory_name returned a different value this time
     292    // than it did originally).
     293    text_t coldir = filename_cat (get_collectdir(args), args["bc1dirname"]);
     294    if (!directory_exists (coldir)) {
     295      message = "reloaderror";
     296      return true;
     297    }
     298      }
     299    } else {
     300      // "collection information" has been changed after collection already exists
    260301      // so we'll need to update the cfg file.
    261302      update_cfgfile_partial (args, logout);
     
    279320    update_cfgfile_clone (args, logout);
    280321  }
    281 
     322 
    282323  if (current_page == "bildstatus") {
    283324    // if .final file exists then build has finished
    284     text_t fbld = filename_cat (gsdlhome, "tmp", args["bc1dirname"] + ".bld.final");
     325    text_t fbld = filename_cat (gsdlhome, "tmp", args["bc1tmp"], args["bc1dirname"] + ".bld.final");
    285326    if (file_exists (fbld)) {
    286327      char *fbldc = fbld.getcstr();
     
    290331    fbld_in.close();
    291332    if (c == '0') current_page = "bilddone";
     333    else if (c == '4' || c == '5') message = "installfail";
    292334    else current_page = "bildfail";
    293335      } else {
     
    304346void collectoraction::update_cfgfile_clone (cgiargsclass &args, ostream &logout) {
    305347
    306   text_t cfgfile = filename_cat(gsdlhome, "collect", args["bc1dirname"], "etc", "collect.cfg");
    307   text_t cfgfile_org = cfgfile + ".org";
     348  text_t tmpdir = filename_cat(gsdlhome, "tmp", args["bc1tmp"]);
     349  text_t cfgfile = filename_cat(tmpdir, args["bc1dirname"], "etc", "collect.cfg");
     350  if (!file_exists (cfgfile)) {
     351    message = "tmpfail";
     352    return;
     353  }
     354
     355  text_t cfgfile_org = filename_cat (tmpdir, "collect.cfg.org");
    308356
    309357  if (args["bc1clone"] == "1") {
     
    314362      // if .org file doesn't exist already create it
    315363      if (!file_exists (cfgfile_org)) {
    316     file_copy (cfgfile, cfgfile_org);
     364    if (!file_copy (cfgfile, cfgfile_org)) {
     365      message = "tmpfail";
     366      return;
     367    }
    317368      }
    318369      // copy clone collections cfg file to new collection
    319       file_copy (cfgfile_clone, cfgfile);
     370      if (!file_copy (cfgfile_clone, cfgfile)) {
     371    message = "tmpfail";
     372    return;
     373      }
    320374      // update the new cfg file
    321375      update_cfgfile_partial (args, logout);
    322376     
    323377    } else {
    324       // can't clone non-existant collection
    325       clone_failed = true;
     378      // can't clone non-existant or read-protected collection
     379      message = "clonefail";
    326380    }
    327381
     
    332386    if (file_exists (cfgfile_org)) {
    333387      // copy original back again and update it with any recent changes
    334       file_copy (cfgfile_org, cfgfile);
    335       update_cfgfile_partial (args, logout);
     388      if (file_copy (cfgfile_org, cfgfile)) {
     389    update_cfgfile_partial (args, logout);
     390      } else {
     391    message = "tmpfail";
     392      }
    336393    }
    337394  }
     
    341398void collectoraction::update_cfgfile_partial (cgiargsclass &args, ostream &logout) {
    342399
    343   text_t cfgfile = filename_cat(gsdlhome, "collect", args["bc1dirname"], "etc", "collect.cfg");
     400  text_t cfgfile = filename_cat(get_collectdir(args), args["bc1dirname"], "etc", "collect.cfg");
    344401  char *cfgfilec = cfgfile.getcstr();
    345402
     
    365422    }
    366423    cfg_in.close();
    367 
     424   
    368425    // now write cfg file back out
    369426#ifdef __WIN32__
     
    380437    logout << "Error: Couldn't lock file " << cfgfilec << "\n";
    381438    cfg_out.close();
     439    message = "tmpfail";
    382440   
    383441      } else {
     
    396454      logout << "collectoraction::update_cfgfile_partial: unable to open "
    397455         << cfgfilec << " for output\n";
    398     }
    399 
     456      message = "tmpfail";
     457    }
     458   
    400459  } else {
    401460    logout << "collectoraction::update_cfgfile_partial: unable to open "
    402461       << cfgfilec << " for input\n";
     462    message = "tmpfail";
    403463  }
    404464  delete cfgfilec;
     
    409469void collectoraction::update_cfgfile_complete (cgiargsclass &args, ostream &logout) {
    410470
    411   text_t cfgfile = filename_cat(gsdlhome, "collect", args["bc1dirname"], "etc", "collect.cfg");
     471  text_t cfgfile = filename_cat(get_collectdir(args), args["bc1dirname"], "etc", "collect.cfg");
    412472  char *cfgfilec = cfgfile.getcstr();
    413473#ifdef __WIN32__
     
    425485      logout << "Error: Couldn't lock file " << cfgfilec << "\n";
    426486      cfg_out.close();
     487      message = "tmpfail";
    427488     
    428489    } else {
     
    455516    logout << "collectoraction::update_cfgfile_complete: unable to open "
    456517           << cfgfilec << " for input\n";
     518    message = "tmpfail";
    457519      }
    458520    }
     
    460522    logout << "collectoraction::update_cfgfile_complete: unable to open "
    461523       << cfgfilec << " for output\n";
     524    message = "tmpfail";
    462525  }
    463526  delete cfgfilec;
     
    598661
    599662// set the _cfgfile_ macro
    600 void collectoraction::set_cfgfile (displayclass &disp, const text_t &dirname, ostream &logout) {
     663void collectoraction::set_cfgfile (displayclass &disp, cgiargsclass &args, ostream &logout) {
     664
     665  text_t &collection = args["bc1dirname"];
     666  if (collection.empty()) {
     667    message = "nocollection";
     668    return;
     669  }
    601670
    602671  // read in collect.cfg     
    603   text_t cfgfile = filename_cat(gsdlhome, "collect", dirname, "etc", "collect.cfg");
     672  text_t cfgfile = filename_cat(get_collectdir(args), collection, "etc", "collect.cfg"); 
    604673  char *cfgfilec = cfgfile.getcstr();
    605674
     
    628697    logout << "collectoraction::set_cfgfile: couldn't open configuration file ("
    629698       << cfgfilec << ") for reading\n";
     699    message = "tmpfail";
    630700  }   
    631701  delete cfgfilec;
     
    633703
    634704// set the _statusline_ macro
    635 void collectoraction::set_statusline (displayclass &disp, const text_t &collection, ostream &logout) {
     705void collectoraction::set_statusline (displayclass &disp, cgiargsclass &args, ostream & /*logout*/) {
    636706
    637707  // the build command creates .bld.download, .bld.import, and .bld.build files (in that
    638708  // order) and deletes them (also in that order) when each stage is complete. the .bld
    639709  // file is the concatenation of all these files.
    640   text_t bld_file = filename_cat (gsdlhome, "tmp", collection + ".bld");
     710  text_t bld_file = filename_cat (gsdlhome, "tmp", args["bc1tmp"], args["bc1dirname"] + ".bld");
    641711  text_t statusline;
    642712
    643713  if (file_exists (bld_file + ".download")) {
    644     statusline = "Downloading files ...<br>";
     714    statusline = "Downloading files ...<br>\n";
    645715    statusline += file_tail (bld_file + ".download");
    646716  } else if (file_exists (bld_file + ".import")) {
    647     statusline = "Importing collection ...<br>";
     717    statusline = "Importing collection ...<br>\n";
    648718    statusline += file_tail (bld_file + ".import");
    649719  } else if (file_exists (bld_file + ".build")) {
    650     statusline = "Building collection ...<br>";
     720    statusline = "Building collection ...<br>\n";
    651721    statusline += file_tail (bld_file + ".build");
    652722  } else {
     723    statusline += "creating collection ...<br>\n";
    653724    statusline += file_tail (bld_file);
    654725  }
     
    677748  disp.setmacro ("pagescriptextra", "collector", "_" + collector_page + "scriptextra_");
    678749
    679   if (collector_page == "bildstatus" || collector_page == "bilddone" || collector_page == "bildfail") {
     750  if (collector_page == "bildstatus" || collector_page == "bilddone" ||
     751      collector_page == "bildfail" || collector_page == "bildframe1") {
    680752    disp.setmacro ("header", "collector", "_" + collector_page + "header_");
    681753  }
     
    759831    collectorbar += get_button (collector_page, "green", "view", true);
    760832    collectorbar += "</tr><tr><td colspan=6></td><td align=center>_icongreyuparrow_</td><td colspan=2></td>\n";
     833
     834  } else if (collector_page == "bildcancel") {
     835    // disable appropriate buttons if we came from "change an existing collection"
     836    // page
     837    if (esrce == 1 || econf == 1) {
     838      collectorbar += get_button (collector_page, "grey", "info", false);
     839    } else {
     840      collectorbar += get_button (collector_page, "yellow", "info", true);
     841    }
     842    collectorbar += "<td>_icongreyarrow_</td>\n";
     843    if (econf == 1) {
     844      collectorbar += get_button (collector_page, "grey", "srce", false);
     845    } else {
     846      collectorbar += get_button (collector_page, "yellow", "srce", true);
     847    }
     848    collectorbar += "<td>_icongreyarrow_</td>\n";
     849    collectorbar += get_button (collector_page, "yellow", "conf", true);
     850    collectorbar += "<td>_icongreyarrow_</td>\n";
     851    collectorbar += get_button (collector_page, "yellow", "bild", true);
     852    collectorbar += "<td>_icongreyarrow_</td>\n";
     853    collectorbar += get_button (collector_page, "grey", "view", false);
    761854  }
    762855
     
    767860    set_fullnamemenu (disp, args, protos, logout);
    768861  if (collector_page == "conf")
    769     set_cfgfile (disp, args["bc1dirname"], logout);
     862    set_cfgfile (disp, args, logout);
    770863  if (collector_page == "bildstatus")
    771     set_statusline (disp, args["bc1dirname"], logout);
     864    set_statusline (disp, args, logout);
    772865}
    773866
     
    781874
    782875  if (collector_page == "bild") {
    783 
    784     // don't want header and stuff for build page as it uses frames
    785     textout << outconvert << disp << ("_collector:bildcontent_\n");
    786 
    787876    // do the work (download, import, build)
    788     text_t tmpdir = filename_cat (gsdlhome, "tmp", collection + ".bld");
    789 
    790     text_t build_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "build");
    791     build_cmd += " -append -remove_import";
    792     build_cmd += " -out \"" + tmpdir + "\"";
    793     if (!args["bc1inputdir1"].empty()) {
    794       build_cmd += " -download \"" + args["bc1inputdir1"] + "\"";
    795     }
    796     if (!args["bc1inputdir2"].empty()) {
    797       build_cmd += " -download \"" + args["bc1inputdir2"] + "\"";
    798     }
    799     if (!args["bc1inputdir3"].empty()) {
    800       build_cmd += " -download \"" + args["bc1inputdir3"] + "\"";
    801     }
    802     if (!args["bc1inputdir4"].empty()) {
    803       build_cmd += " -download \"" + args["bc1inputdir4"] + "\"";
    804     }
    805     build_cmd.push_back (' ');
    806     build_cmd += collection;
    807 
    808 #if !defined (__WIN32__)
    809     // run in background on unix systems
    810     build_cmd += " &";
    811 #endif
    812     char *build_cmdc = build_cmd.getcstr();
    813 #if defined (__WIN32__)
    814     gsdl_system (build_cmdc, logout);
    815 #else
    816     system (build_cmdc);
    817 #endif
    818     delete build_cmdc;
    819 
    820   } else {
    821 
    822     // not bild page
    823 
    824     text_t message;
    825 
    826     if (do_mkcol) {
    827       // execute mkcol.pl (do_mkcol is set from within check_cgiargs)
    828       text_t mkcol_cmd = "perl ";
    829       mkcol_cmd += filename_cat (gsdlhome, "bin", "script", "mkcol.pl");
    830       mkcol_cmd += " -creator \"" + args["bc1contactemail"] + "\"";
    831       mkcol_cmd += " -title \"" + args["bc1fullname"] + "\"";
    832       mkcol_cmd += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\" ";
    833       mkcol_cmd += collection;
    834       char *mkcol_cmdc = mkcol_cmd.getcstr();
    835       system (mkcol_cmdc);
    836       delete mkcol_cmdc;
    837      
    838       // make sure it went ok
    839       text_t cfgfile = filename_cat (gsdlhome, "collect", collection,
    840                      "etc", "collect.cfg");
    841       if (!file_writable (cfgfile)) message = "mkcolfail";
    842       do_mkcol = false; // reset for fast-cgi
    843     }
    844 
    845     if (args["bc1dodelete"] == "1") {
    846       // delete bcidirname collection
    847       if (collection_protected (collection)) {
    848     message = "delinvalid";
     877    gsdl_build (args, logout);
     878
     879    if (message.empty()) {
     880      // bild page is a frameset so we don't want headers and stuff
     881      textout << outconvert << disp << ("_collector:bildcontent_\n");
     882    }
     883  }
     884
     885  if (do_mkcol == true) {
     886    // execute mkcol.pl (do_mkcol is set from within check_cgiargs)
     887    gsdl_mkcol (args, logout);
     888    do_mkcol = false; // reset for fast-cgi
     889  }
     890
     891  if (args["bc1dodelete"] == "1") {
     892    // delete bcidirname collection
     893    if (collection_protected (collection)) {
     894      message = "delinvalid";
    849895   
     896    } else {
     897   
     898      text_t delete_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "delcol.pl");
     899      delete_cmd += " -f " + collection;
     900      char *delete_cmdc = delete_cmd.getcstr();
     901      int rv = system (delete_cmdc);
     902      delete delete_cmdc;
     903      if (rv != 0) {
     904    // deletion failed -- permissions?
     905    message = "delpermission";
    850906      } else {
    851    
    852     text_t delete_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "delcol.pl");
    853     delete_cmd += " -f " + collection;
    854     char *delete_cmdc = delete_cmd.getcstr();
    855     int rv = system (delete_cmdc);
    856     delete delete_cmdc;
    857     if (rv != 0) {
    858       // deletion failed -- permissions?
    859       message = "delpermission";
    860     } else {
    861       message = "delsuccess";
    862     }
    863       }
    864     }
    865    
    866     if (clone_failed) {
    867       // clone_failed is set from check_cgiargs if an attempt was made
    868       // to clone an invalid collection
    869       message = "clonefail";
    870       clone_failed = false;
    871     }
    872    
    873     if (message.empty()) {
     907    message = "delsuccess";
     908      }
     909    }
     910  }
     911 
     912  if (collector_page == "bildcancel") {
     913    // cancel the build
     914    gsdl_cancel_build (args, logout);
     915  }
     916
     917  if (message.empty()) {
     918    if (collector_page != "bild") {
     919      // output page ("bild" page was already output above)
    874920      textout << outconvert << disp << ("_collector:header_\n")
    875921          << ("_collector:" + collector_page + "content_\n")
    876922          << ("_collector:footer_\n");
    877     } else {
    878       textout << outconvert << disp << ("_collector:header_\n")
    879           << ("_collector:" + message + "content_\n")
    880           << ("_collector:footer_\n");
    881     }
     923    }
     924  } else {
     925    // message was set somewhere (probably an error), output message page
     926    textout << outconvert << disp << ("_collector:header_\n")
     927        << ("_collector:" + message + "content_\n")
     928        << ("_collector:footer_\n");
     929    message.clear();
    882930  }
    883931  return true;
     
    887935// else replace all occurances of "\n" with a carriage return
    888936text_t collectoraction::carriage_replace (const text_t &intext, int sw) {
    889 
     937   
    890938  text_t outtext;
    891939  text_t::const_iterator here = intext.begin();
     
    9841032  return true;
    9851033}
     1034
     1035// assigns a temporary directory name for this collector session
     1036// and creates temporary directory
     1037void collectoraction::assign_tmpname (cgiargsclass &args, ostream &logout) {
     1038
     1039  int i = 0;
     1040  text_t tmpname = "tbuild";
     1041  while (directory_exists (filename_cat (gsdlhome, "tmp", tmpname + text_t(i)))) {
     1042    i++;
     1043  }
     1044  tmpname.appendint (i);
     1045
     1046  text_t fulltmpdir = filename_cat (gsdlhome, "tmp", tmpname);
     1047  if (!mk_dir (fulltmpdir)) {
     1048    outconvertclass text_t2ascii;
     1049    logout << text_t2ascii << "collectoraction::assign_tmpname unable to create directory ("
     1050       << fulltmpdir << ")\n";
     1051  }
     1052
     1053  args["bc1tmp"] = tmpname;
     1054}
     1055
     1056void collectoraction::gsdl_mkcol (cgiargsclass &args, ostream &logout) {
     1057
     1058  text_t tmpdir = filename_cat (gsdlhome, "tmp", args["bc1tmp"]);
     1059  if (!directory_exists (tmpdir)) {
     1060    message = "tmpfail";
     1061    return;
     1062  }
     1063
     1064  text_t &collection = args["bc1dirname"];
     1065  if (collection.empty()) {
     1066    message = "nocollection";
     1067    return;
     1068  }
     1069
     1070  // check for a .create file - if it exists then we've already created the collection
     1071  text_t createfile = filename_cat (tmpdir, ".create");
     1072  if (file_exists (createfile)) {
     1073    return;
     1074  } else {
     1075    // create the .create file (this file is just a place holder to let any future
     1076    // pages know that the collection already exists).
     1077    char *createfilec = createfile.getcstr();
     1078    ofstream cfile_out (createfilec);
     1079    delete createfilec;
     1080    if (cfile_out) {
     1081      cfile_out << "collection created\n";
     1082      cfile_out.close();
     1083    } else {
     1084      message = "tmpfail";
     1085      return;
     1086    }
     1087  }
     1088
     1089  // set up options
     1090  text_t options = "-creator \"" + args["bc1contactemail"] + "\"";
     1091  options += " -title \"" + args["bc1fullname"] + "\"";
     1092  options += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\"";
     1093  options += " -collectdir \"" + tmpdir + "\" ";
     1094  text_t optionfile = filename_cat (tmpdir, "mkcol.opt");
     1095  char *optionfilet = optionfile.getcstr();
     1096  ofstream ofile_out (optionfilet);
     1097  delete optionfilet;
     1098  if (!ofile_out) {
     1099    message = "tmpfail";
     1100    return;
     1101  }
     1102  outconvertclass text_t2ascii;
     1103  ofile_out << text_t2ascii << options << "\n";
     1104  ofile_out.close();
     1105 
     1106  // set up the mkcol.pl command
     1107  text_t mkcol_cmd = "perl ";
     1108  mkcol_cmd += filename_cat (gsdlhome, "bin", "script", "mkcol.pl");
     1109  mkcol_cmd += " -optionfile \"" + optionfile + "\" " + collection;
     1110  char *mkcol_cmdc = mkcol_cmd.getcstr();
     1111 
     1112  // just an ordinary system call running in the foreground. we're assuming (hoping??)
     1113  // that mkcol.pl will run through fast enough that nothing more elaborate is required.
     1114  system (mkcol_cmdc);
     1115  delete mkcol_cmdc;
     1116 
     1117  // make sure it went ok
     1118  text_t cfgfile = filename_cat (tmpdir, collection, "etc", "collect.cfg");
     1119  if (!file_writable (cfgfile)) {
     1120    message = "mkcolfail";
     1121  }
     1122}
     1123
     1124void collectoraction::gsdl_build (cgiargsclass &args, ostream &logout) {
     1125
     1126  text_t tmpdir = filename_cat (gsdlhome, "tmp", args["bc1tmp"]);
     1127  if (!directory_exists (tmpdir)) {
     1128    message = "tmpfail";
     1129    return;
     1130  }
     1131 
     1132  text_t &collection = args["bc1dirname"];
     1133  if (collection.empty()) {
     1134    message = "nocollection";
     1135    return;
     1136  }
     1137
     1138  // check for a .build file - if it exists then we've already built
     1139  // the collection (or are in the process of building it)
     1140  text_t buildfile = filename_cat (tmpdir, ".build");
     1141  if (file_exists (buildfile)) {
     1142    return;
     1143  } else {
     1144    // create the .build file (this file is just a place holder to let any future
     1145    // pages know that we've already been here)
     1146    char *buildfilec = buildfile.getcstr();
     1147    ofstream bfile_out (buildfilec);
     1148    delete buildfilec;
     1149    if (bfile_out) {
     1150      bfile_out << "collection building\n";
     1151      bfile_out.close();
     1152    } else {
     1153      message = "tmpfail";
     1154      return;
     1155    }
     1156  }
     1157
     1158  // set up build options
     1159  text_t options = "-remove_import -out \"";
     1160  options += filename_cat (tmpdir, collection + ".bld");
     1161  if (args["bc1esrce"] == 1) {
     1162    // we're adding data to an existing collection
     1163    options += "\" -save_archives -append";
     1164  } else {
     1165    options += "\" -collectdir \"" + tmpdir + "\"";
     1166  }
     1167  if (!args["bc1inputdir1"].empty())
     1168    options += " -download \"" + args["bc1inputdir1"] + "\"";
     1169  if (!args["bc1inputdir2"].empty())
     1170    options += " -download \"" + args["bc1inputdir2"] + "\"";
     1171  if (!args["bc1inputdir3"].empty())
     1172    options += " -download \"" + args["bc1inputdir3"] + "\"";
     1173  if (!args["bc1inputdir4"].empty())
     1174    options += " -download \"" + args["bc1inputdir4"] + "\"";
     1175  text_t optionfile = filename_cat (tmpdir, "build.opt");
     1176  char *optionfilet = optionfile.getcstr();
     1177  ofstream ofile_out (optionfilet);
     1178  delete optionfilet;
     1179  if (!ofile_out) {
     1180    message = "tmpfail";
     1181    return;
     1182  }
     1183  outconvertclass text_t2ascii;
     1184  ofile_out << text_t2ascii << options << "\n";
     1185  ofile_out.close();
     1186
     1187  // set up the build command
     1188  text_t build_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "build");
     1189  build_cmd += " -optionfile \"" + optionfile + "\" " + collection;
     1190#if !defined (__WIN32__)
     1191  // run in background on unix systems
     1192  //  build_cmd += " &";
     1193#endif
     1194  char *build_cmdc = build_cmd.getcstr();
     1195  //#if defined (__WIN32__)
     1196  gsdl_system (build_cmdc, logout);
     1197  //#else
     1198  //  system (build_cmdc);
     1199  //#endif
     1200  delete build_cmdc;
     1201}
     1202
     1203void collectoraction::gsdl_cancel_build (cgiargsclass &args, ostream &logout) {
     1204  // I really wanted to do what this perl script does from within the library
     1205  // c++ code. I ran into some problems though (like how do you write a portable
     1206  // "rm -r" in c++?). One day I'll spend some time sorting it out ... maybe.
     1207  text_t cancel_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "cancel_build.pl");
     1208  cancel_cmd += " -collectdir \"" + get_collectdir(args) + "\" " + args["bc1dirname"];
     1209  char *cancel_cmdc = cancel_cmd.getcstr();
     1210  system (cancel_cmdc);
     1211  delete (cancel_cmdc);
     1212}
     1213
     1214text_t collectoraction::get_collectdir (cgiargsclass &args) {
     1215
     1216  if ((args["bc1econf"] == 1) || (args["bc1esrce"] == 1)) {
     1217    // we're adding to a collection in place
     1218    return filename_cat(gsdlhome, "collect"); 
     1219
     1220  } else {
     1221    return filename_cat (gsdlhome, "tmp", args["bc1tmp"]);
     1222  }
     1223}
  • trunk/gsdl/src/recpt/collectoraction.h

    r1437 r1457  
    3939  char *gsdlhomec;
    4040
     41  text_t message;
     42
    4143  bool do_mkcol;
    42   bool clone_failed;
    4344
    4445  text_t get_button (const text_t &thispage, const text_t &color,
     
    4849             recptprotolistclass *protos, ostream &logout);
    4950
    50   void set_cfgfile (displayclass &disp, const text_t &dirname, ostream &logout);
     51  void set_cfgfile (displayclass &disp, cgiargsclass &args, ostream &logout);
    5152
    52   void set_statusline (displayclass &disp, const text_t &collection, ostream &logout);
     53  void set_statusline (displayclass &disp, cgiargsclass &args, ostream &logout);
    5354
    5455  void update_cfgfile_clone (cgiargsclass &args, ostream &logout);
     
    6364
    6465  bool collection_protected (const text_t &collection);
     66
     67  void assign_tmpname (cgiargsclass &args, ostream &logout);
     68
     69  void gsdl_mkcol (cgiargsclass &args, ostream &logout);
     70
     71  void gsdl_build (cgiargsclass &args, ostream &logout);
     72
     73  void gsdl_cancel_build (cgiargsclass &args, ostream &logout);
     74
     75  text_t get_collectdir (cgiargsclass &args);
    6576
    6677public:
Note: See TracChangeset for help on using the changeset viewer.