]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_upgrade.c
* Merged in code from the TRANSACTIONS branch for testing.
[citadel.git] / citadel / serv_upgrade.c
index 1f31a3b59025db76a4c9a8c25ff30b9a88f63575..51d0e430f25baa4093cc18945c745627d15798c1 100644 (file)
@@ -1,4 +1,10 @@
-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Transparently handle the upgrading of server data formats.
+ *
+ */
+
 #include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
@@ -43,6 +49,7 @@ void do_pre555_usersupp_upgrade(void) {
        strcpy(tempfilename, tmpnam(NULL));
 
        /* First, back out all old version records to a flat file */
+       cdb_begin_transaction();
         cdb_rewind(CDB_USERSUPP);
         while(cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
                 memset(&usbuf, 0, sizeof(struct pre555usersupp));
@@ -52,6 +59,7 @@ void do_pre555_usersupp_upgrade(void) {
                 cdb_free(cdbus);
                fwrite(&usbuf, sizeof(struct pre555usersupp), 1, fp);
        }
+       cdb_end_transaction();
 
        /* ...and overwrite the records with new format records */
        rewind(fp);
@@ -96,7 +104,7 @@ void do_pre555_usersupp_upgrade(void) {
                fwrite(vcard, strlen(vcard)+1, 1, tp);
                fclose(tp);
 
-               CtdlWriteObject(CONFIGROOM, "text/x-vcard",
+               CtdlWriteObject(USERCONFIGROOM, "text/x-vcard",
                        tempfilename, &newus, 0, 1, CM_SKIP_HOOKS);
                unlink(tempfilename);
            }
@@ -119,7 +127,7 @@ void check_server_upgrades(void) {
                (CitControl.version / 100),
                (CitControl.version % 100) );
 
-       if (CitControl.version < config.c_setup_level) {
+       if (CitControl.version < REV_LEVEL) {
                lprintf(5, "Server hosted updates need to be processed at "
                                "this time.  Please wait...\n");
        }
@@ -127,11 +135,9 @@ void check_server_upgrades(void) {
                return;
        }
 
-
        if (CitControl.version < 555) do_pre555_usersupp_upgrade();
 
-
-       CitControl.version = config.c_setup_level;
+       CitControl.version = REV_LEVEL;
        put_control();
 }