Browse code

freshdbdir now supports daily.inc

git-svn: trunk@2463

Tomasz Kojm authored on 2006/10/30 04:13:11
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sun Oct 29 20:12:26 CET 2006 (tk)
2
+---------------------------------
3
+  * shared/misc.c: freshdbdir now supports daily.inc
4
+
1 5
 Sun Oct 29 19:45:07 CET 2006 (tk)
2 6
 ---------------------------------
3 7
   * clamd: change stack size at the right place (closes bug#103)
... ...
@@ -48,24 +48,30 @@
48 48
 #define	O_BINARY	0
49 49
 #endif
50 50
 
51
-
52
-/* TODO: add support for incremental directories */
53 51
 char *freshdbdir(void)
54 52
 {
55 53
 	struct cl_cvd *d1, *d2;
56 54
 	struct cfgstruct *copt = NULL, *cpt;
55
+	struct stat foo;
57 56
 	const char *dbdir;
58 57
 	char *retdir;
59 58
 
59
+
60 60
     /* try to find fresh directory */
61 61
     dbdir = cl_retdbdir();
62 62
     if((copt = getcfg(CONFDIR"/clamd.conf", 0))) {
63 63
 	if((cpt = cfgopt(copt, "DatabaseDirectory"))->enabled || (cpt = cfgopt(copt, "DataDirectory"))->enabled) {
64 64
 	    if(strcmp(dbdir, cpt->strarg)) {
65
-		    char *daily = (char *) mmalloc(strlen(cpt->strarg) + strlen(dbdir) + 15);
65
+		    char *daily = (char *) mmalloc(strlen(cpt->strarg) + strlen(dbdir) + 30);
66 66
 		sprintf(daily, "%s/daily.cvd", cpt->strarg);
67
+		if(stat(daily, &foo) == -1)
68
+		    sprintf(daily, "%s/daily.inc/daily.info", cpt->strarg);
69
+
67 70
 		if((d1 = cl_cvdhead(daily))) {
68 71
 		    sprintf(daily, "%s/daily.cvd", dbdir);
72
+		    if(stat(daily, &foo) == -1)
73
+			sprintf(daily, "%s/daily.inc/daily.info", dbdir);
74
+
69 75
 		    if((d2 = cl_cvdhead(daily))) {
70 76
 			free(daily);
71 77
 			if(d1->version > d2->version)
... ...
@@ -91,7 +97,6 @@ char *freshdbdir(void)
91 91
     return retdir;
92 92
 }
93 93
 
94
-/* TODO: add _proper_ support for incremental directories */
95 94
 void print_version(void)
96 95
 {
97 96
 	char *dbdir;