Ver código fonte

fixed error in matching

root 9 anos atrás
pai
commit
5a0109048e
5 arquivos alterados com 56 adições e 44 exclusões
  1. BIN
      bin/kind
  2. 1 1
      src/DateTime.cpp
  3. 1 0
      src/DateTime.h
  4. 12 1
      src/expiretools.cpp
  5. 42 42
      src/kind.cpp

BIN
bin/kind


+ 1 - 1
src/DateTime.cpp

@@ -53,7 +53,7 @@ bool DateTime::match(const set<int>& Y, const set<int>& M, const set<int>& D,
 {
   tm* tm = localtime(&theTime);
   return match(Y, tm->tm_year) &&
-         match(M, tm->tm_mon - 1) &&
+         match(M, tm->tm_mon + 1) &&
          match(D, tm->tm_mday) &&
          match(W, tm->tm_wday) &&
          match(h, tm->tm_hour) &&

+ 1 - 0
src/DateTime.h

@@ -3,6 +3,7 @@
 
 #include <set>
 #include <string>
+#include <iostream>
 #include <time.h>
 
 class DateTime

+ 12 - 1
src/expiretools.cpp

@@ -102,7 +102,18 @@ DateTime getExpireDate(const DateTime& imageTime, const KindConfig& conf, string
       set<int> Y, m, s;
       time_t expirePeriod;
       parseRule(expireRules[k], M, D, W, h, expirePeriod);
-
+#if 0
+      cout << expireRules[k] << endl;
+      for (auto v:M) cout << v << " ";
+      cout << endl;
+      for (auto v:D) cout << v << " ";
+      cout << endl;
+      for (auto v:W) cout << v << " ";
+      cout << endl;
+      for (auto v:h) cout << v << " ";
+      cout << endl;
+      cout << imageTime.getString('m') << endl;
+#endif
       if (imageTime.match(Y, M, D, W, h, m, s))
         {
           debugPrint("match");

+ 42 - 42
src/kind.cpp

@@ -281,9 +281,9 @@ bool isValidImage(const string& imageName)
 # 137 "kind.ag"
   return dirExists(imageName) &&
 # 138 "kind.ag"
-  !fileExists(imageName + "/error") &&
+         !fileExists(imageName + "/error") &&
 # 139 "kind.ag"
-  dirExists(imageName + "/tree");
+         dirExists(imageName + "/tree");
 # 140 "kind.ag"
 }
 # 141 "kind.ag"
@@ -501,7 +501,7 @@ void backupVault(const string& vault,
 # 247 "kind.ag"
           string userAtHost = conf.getString("user") + "@" +
 # 248 "kind.ag"
-          conf.getString("host");
+                              conf.getString("host");
 # 249 "kind.ag"
           string rshCommand = remoteShell;
 # 250 "kind.ag"
@@ -689,9 +689,9 @@ void backupVault(const string& vault,
 # 341 "kind.ag"
           if (rc == 0 ||
 # 342 "kind.ag"
-          rc == 24 || // "no error" or "vanished source files" (ignored)
+              rc == 24 || // "no error" or "vanished source files" (ignored)
 # 343 "kind.ag"
-          rc == 6114) // workaround for wrong exit code ??!!
+              rc == 6114) // workaround for wrong exit code ??!!
 # 344 "kind.ag"
             {
 # 345 "kind.ag"
@@ -1095,9 +1095,9 @@ void expireVault(const string& vault, KindConfig conf, DateTime now)
 # 544 "kind.ag"
   for (unsigned int i = 0;
 # 545 "kind.ag"
-  i < validImages.size() - 1; // never expire latest image
+       i < validImages.size() - 1; // never expire latest image
 # 546 "kind.ag"
-  ++i)
+       ++i)
 # 547 "kind.ag"
     {
 # 548 "kind.ag"
@@ -1159,10 +1159,10 @@ string ag_programName;
 void usage()
 {
   cout << ag_programName << " - archiving backup" << endl;
-  cout << "Usage:" << endl;
+  cout << "Aufruf:" << endl;
   cout << ag_programName << " [<options>] vault_or_group " << endl;
   cout << "  vault_or_group - Vault to backup" << endl;
-  cout << "Options:" << endl;
+  cout << "Optionen:" << endl;
   cout << "  -f --full          Force full image == initial backup (default: false)" << endl;
   cout << "  -c --masterconfig  Master config file (default: \"\")" << endl;
   cout << "                     if not given or empty kind looks for" << endl;
@@ -1179,15 +1179,15 @@ void usage()
   exit(1);
 }
 
-void error(const string& msg)
+void error(const string &msg)
 {
   cout << endl << ag_programName << " - error: " << msg << endl << endl;
   usage();
 }
 
-int ptoi(const char* para)
+int ptoi(const char *para)
 {
-  char* end;
+  char *end;
   int res = strtol(para, &end, 10);
   if (end == para)
     error(string("no int: ") + para);
@@ -1196,9 +1196,9 @@ int ptoi(const char* para)
   return res;
 }
 
-double ptod(const char* para)
+double ptod(const char *para)
 {
-  char* end;
+  char *end;
   double res = strtod(para, &end);
   if (end == para)
     error(string("no double: ") + para);
@@ -1207,15 +1207,15 @@ double ptod(const char* para)
   return res;
 }
 
-int main(int argc, char** argv)
+int main(int argc, char **argv)
 {
-  bool fullImage = false;
-  string masterConfig = "";
-  bool backupOnly = false;
-  bool expireOnly = false;
-  bool listConfig = false;
+bool fullImage = false;
+string masterConfig = "";
+bool backupOnly = false;
+bool expireOnly = false;
+bool listConfig = false;
 
-  string vault = "";
+string vault = "";
   static struct option ag_long_options[] =
   {
     {"full", no_argument, 0, 'f' },
@@ -1244,44 +1244,44 @@ int main(int argc, char** argv)
           error("Expecting option parameter");
           break;
         case 'f':
-          fullImage = true;
-          break;
+              fullImage = true;
+              break;
 
         case 'c':
-          masterConfig = optarg;
-          break;
+              masterConfig = optarg;
+              break;
 
         case 'B':
-          backupOnly = true;
-          break;
+              backupOnly = true;
+              break;
 
         case 'E':
-          expireOnly = true;
-          break;
+              expireOnly = true;
+              break;
 
         case 'D':
-          dryRun = true;
-          break;
+              dryRun = true;
+              break;
 
         case 'C':
-          listConfig = true;
-          break;
+              listConfig = true;
+              break;
 
         case 'v':
-          verbose = true;
-          break;
+              verbose = true;
+              break;
 
         case 'd':
-          debug = true;
-          break;
+              debug = true;
+              break;
 
         case 'q':
-          quiet = true;
-          break;
+              quiet = true;
+              break;
 
         case 'h':
-          usage();
-          break;
+              usage();
+              break;
 
         default:
           error("error in options");
@@ -1291,7 +1291,7 @@ int main(int argc, char** argv)
     vault = argv[optind++];
   else error("Parameter vault_or_group needed");
 
-  /*AppGen:MainEnd*/
+/*AppGen:MainEnd*/
 # 578 "kind.ag"
 
 # 579 "kind.ag"