]> code.citadel.org Git - citadel.git/commitdiff
* cdb_cull_logs() now removes log files as soon as the log_archive() function
authorArt Cancro <ajc@citadel.org>
Sun, 9 Sep 2001 03:19:38 +0000 (03:19 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 9 Sep 2001 03:19:38 +0000 (03:19 +0000)
  says it's ok to do so.

citadel/ChangeLog
citadel/database_sleepycat.c

index 112ae7c10d57a59cfc2d348a9827aa4b1424c092..7431ad098f5a8dcb761b4b08710005b3379b43b3 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 580.40  2001/09/09 03:19:38  ajc
+ * cdb_cull_logs() now removes log files as soon as the log_archive() function
+   says it's ok to do so.
+
  Revision 580.39  2001/09/08 18:58:38  ajc
  * More changes to the new networker.  Added client command for room sharing.
 
@@ -2734,3 +2738,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index ef648647c8dbc0f35b6d12005473fb5076a2d2e1..0af8b4b5a4200bf3f032567775ddb00c7cb5e35c 100644 (file)
@@ -174,31 +174,28 @@ void defrag_databases(void)
  * Cull the database logs
  */
 static void cdb_cull_logs(void) {
-       DIR *dp;
-       struct dirent *d;
-       char filename[SIZ];
-       struct stat statbuf;
+       u_int32_t flags;
+       int ret;
+       char **file, **list;
 
        lprintf(5, "Database log file cull started.\n");
 
-       dp = opendir("data");
-       if (dp == NULL) return;
-
-       while (d = readdir(dp), d != NULL) {
-               if (!strncasecmp(d->d_name, "log.", 4)) {
-                       sprintf(filename, "./data/%s", d->d_name);
-                       stat(filename, &statbuf);
-                       if ((time(NULL) - statbuf.st_mtime) > 432000L) {
-                               lprintf(5, "%s ... deleted\n", filename);
-                               unlink(filename);
-                       }
-                       else {
-                               lprintf(5, "%s ... kept\n", filename);
-                       }
-               }
+       flags = DB_ARCH_ABS;
+
+       /* Get the list of names. */
+       if ((ret = log_archive(dbenv, &list, flags)) != 0) {
+               lprintf(1, "cdb_cull_logs: %s\n", db_strerror(ret));
+               return;
        }
 
-       closedir(dp);
+       /* Print the list of names. */
+       if (list != NULL) {
+               for (file = list; *file != NULL; ++file) {
+                       lprintf(9, "Deleting log: %s\n", *file);
+                       unlink(*file);
+               }
+               free(list);
+       }
 
        lprintf(5, "Database log file cull ended.\n");
 }