Ignore:
Timestamp:
2008-07-09T13:12:15+12:00 (16 years ago)
Author:
davidb
Message:

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/colservr/source.cpp

    r15680 r16310  
    5252    else if (key == "collectdir") collectdir = value;
    5353    else if (key == "gsdlhome") gsdlhome = value;
     54    else if (key == "collecthome") collecthome = value;
    5455    else if (key == "gdbmhome") dbhome = value;
    5556  }
     
    7778}
    7879
     80text_t sourceclass::resolve_db_filename(const text_t& idx,
     81                    const text_t& file_ext)
     82{
     83  // This is an exact copy of the method (of the same name) in filterclass
     84  // Makes sense to merge them, in which either gsdlhome, collecthome,
     85  // dbhome, and collection need to also be passed in as parameters,
     86  // or else there is some notion of a shared base class that both
     87  // filter and source inherit from
     88
     89  // NB: there is an even greater opportunity to share more code in this
     90  // function if sql_db_ptr/db_ptr and db_filename and sql_db_filename
     91  // are also drawn from one object
     92
     93  text_t resolved_filename;
     94
     95  if (gsdlhome==dbhome) {
     96    // dbhome has defaulted to gsdlhome which we take to means the
     97    // database has been specifically moved out of gsdlhome area.
     98    // => it should be whereever collecthome is set to
     99
     100    resolved_filename = filename_cat(collecthome, collection, "index", "text", idx);
     101  }
     102  else {
     103    // dbhome is explicitly set to something other than gsdlhome
     104    // => use dbhome
     105    resolved_filename = filename_cat(dbhome, "collect", collection, "index", "text", idx);
     106  }
     107
     108  resolved_filename += file_ext;
     109
     110  return resolved_filename;
     111}
     112
     113
     114
    79115// init should be called after all the configuration is done but
    80116// before any other methods are called
     
    83119  outconvertclass text_t2ascii;
    84120 
     121  if (collecthome.empty()) collecthome = filename_cat(gsdlhome,"collect");
    85122  if (dbhome.empty()) dbhome = gsdlhome;
    86123
     
    114151  // get the collection directory name
    115152  if (collectdir.empty()) {
    116     collectdir = filename_cat (gsdlhome, "collect", collection);
     153    collectdir = filename_cat (collecthome, collection);
    117154  }
    118155
     
    128165    indexstem = collection;
    129166  }
    130   db_filename = filename_cat(dbhome, "collect", collection, "index", "text", indexstem);
    131   db_filename += db_ptr->getfileextension();
     167  db_filename = resolve_db_filename(indexstem, db_ptr->getfileextension());
    132168  if (!file_exists(db_filename)) {
    133169    logout << text_t2ascii
Note: See TracChangeset for help on using the changeset viewer.