From b4b389c27e56ec39cda696f75d527a46339f44b9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 9 Oct 2008 21:24:12 -0400 Subject: [PATCH] - Added checks to ensure that a shadow.file value doesn't collide with either the pending.data or completed.data files. --- src/task.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/task.cpp b/src/task.cpp index 8e3b530b1..e43994e53 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -301,14 +301,27 @@ int main (int argc, char** argv) TDB tdb; gTdb = &tdb; - tdb.dataDirectory (expandPath (conf.get ("data.location"))); + std::string dataLocation = expandPath (conf.get ("data.location")); + tdb.dataDirectory (dataLocation); // Log commands, if desired. if (conf.get ("command.logging") == "on") tdb.logCommand (argc, argv); // Set up TDB callback. - tdb.onChange (&onChangeCallback); + std::string shadowFile = expandPath (conf.get ("shadow.file")); + if (shadowFile != "") + { + if (shadowFile == dataLocation + "/pending.data") + throw std::string ("Configuration variable 'shadow.file' is set to " + "overwrite your pending tasks. Please change it."); + + if (shadowFile == dataLocation + "/completed.data") + throw std::string ("Configuration variable 'shadow.file' is set to " + "overwrite your completed tasks. Please change it."); + + tdb.onChange (&onChangeCallback); + } runTaskCommand (argc, argv, tdb, conf); }