X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fmigrate%2Fserv_migrate.c;h=e4d39d0ece7407372d4413b0a038d87ed1d170ea;hb=e8123a34d5c13c89443de540f8d3ef10f53225a6;hp=2005864a1f03f6ba4367a05098df5ddfb408f800;hpb=c382f04eece05b2b94ce07b5066c524f4359ced2;p=citadel.git diff --git a/citadel/modules/migrate/serv_migrate.c b/citadel/modules/migrate/serv_migrate.c index 2005864a1..e4d39d0ec 100644 --- a/citadel/modules/migrate/serv_migrate.c +++ b/citadel/modules/migrate/serv_migrate.c @@ -1,7 +1,7 @@ /* * This module dumps and/or loads the Citadel database in XML format. * - * Copyright (c) 1987-2014 by the citadel.org team + * Copyright (c) 1987-2015 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -12,6 +12,20 @@ * GNU General Public License for more details. */ +/* + * Explanation of tags: + * + * 0% nothing + * 1% finished exporting config + * 2% finished exporting control + * 7% finished exporting users + * 12% finished exporting openids + * 17% finished exporting rooms + * 18% finished exporting floors + * 25% finished exporting visits + * 100% finished exporting messages + */ + #include "sysdep.h" #include #include @@ -56,6 +70,7 @@ char migr_tempfilename1[PATH_MAX]; char migr_tempfilename2[PATH_MAX]; FILE *migr_global_message_list; +int total_msgs = 0; /* @@ -69,6 +84,10 @@ void xml_strout(char *str) { char *c = str; + if (str == NULL) { + return; + } + while (*c != 0) { if (*c == '\"') { client_write(""", 6); @@ -180,6 +199,19 @@ void migr_export_rooms(void) { if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno); snprintf(cmd, sizeof cmd, "uniq <%s >%s", migr_tempfilename2, migr_tempfilename1); if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno); + + + snprintf(cmd, sizeof cmd, "wc -l %s", migr_tempfilename1); + FILE *fp = popen(cmd, "r"); + if (fp) { + fgets(cmd, sizeof cmd, fp); + pclose(fp); + total_msgs = atoi(cmd); + } + else { + total_msgs = 1; // any nonzero just to keep it from barfing + } + syslog(LOG_DEBUG, "Total messages to be exported: %d", total_msgs); } @@ -353,6 +385,8 @@ void migr_export_messages(void) { char buf[SIZ]; long msgnum; int count = 0; + int progress = 0; + int prev_progress = 0; CitContext *Ctx; Ctx = CC; @@ -366,6 +400,11 @@ void migr_export_messages(void) { migr_export_message(msgnum); ++count; } + progress = (count * 74 / total_msgs) + 25 ; + if ((progress > prev_progress) && (progress < 100)) { + cprintf("%d\n", progress); + } + prev_progress = progress; } fclose(migr_global_message_list); } @@ -389,6 +428,7 @@ void migr_do_export(void) { client_write("\n", 40); client_write("\n", 23); cprintf("%d\n", REV_LEVEL); + cprintf("%d\n", 0); /* export the config file (this is done using x-macros) */ client_write("\n", 9); @@ -396,7 +436,6 @@ void migr_do_export(void) { client_write("", 8); xml_strout(config.c_fqdn); client_write("\n", 10); client_write("", 13); xml_strout(config.c_humannode); client_write("\n", 15); client_write("", 12); xml_strout(config.c_phonenum); client_write("\n", 14); - cprintf("%d\n", config.c_ctdluid); cprintf("%d\n", config.c_creataide); cprintf("%d\n", config.c_sleeping); cprintf("%d\n", config.c_initax); @@ -465,7 +504,9 @@ void migr_do_export(void) { cprintf("%ld\n", config.c_pop3_fastest); cprintf("%d\n", config.c_spam_flag_only); cprintf("%d\n", config.c_nntp_port); + cprintf("%d\n", config.c_nntps_port); client_write("\n", 10); + cprintf("%d\n", 1); /* Export the control file */ get_control(); @@ -474,16 +515,23 @@ void migr_do_export(void) { cprintf("%u\n", CitControl.MMflags); cprintf("%ld\n", CitControl.MMnextuser); cprintf("%ld\n", CitControl.MMnextroom); - cprintf("%d\n", CitControl.version); + cprintf("%d\n", CitControl.MM_hosted_upgrade_level); client_write("\n", 11); + cprintf("%d\n", 2); if (Ctx->kill_me == 0) migr_export_users(); + cprintf("%d\n", 7); if (Ctx->kill_me == 0) migr_export_openids(); + cprintf("%d\n", 12); if (Ctx->kill_me == 0) migr_export_rooms(); + cprintf("%d\n", 17); if (Ctx->kill_me == 0) migr_export_floors(); + cprintf("%d\n", 18); if (Ctx->kill_me == 0) migr_export_visits(); + cprintf("%d\n", 25); if (Ctx->kill_me == 0) migr_export_messages(); client_write("\n", 24); + cprintf("%d\n", 100); client_write("000\n", 4); Ctx->dont_term = 0; } @@ -575,7 +623,6 @@ int migr_config(void *data, const char *el) else if (!strcasecmp(el, "c_fqdn")) SET_CFGSTRBUF(c_fqdn, migr_chardata); else if (!strcasecmp(el, "c_humannode")) SET_CFGSTRBUF(c_humannode, migr_chardata); else if (!strcasecmp(el, "c_phonenum")) SET_CFGSTRBUF(c_phonenum, migr_chardata); - else if (!strcasecmp(el, "c_ctdluid")) config.c_ctdluid = atoi(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "c_creataide")) config.c_creataide = atoi(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "c_sleeping")) config.c_sleeping = atoi(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "c_initax")) config.c_initax = atoi(ChrPtr(migr_chardata)); @@ -644,6 +691,7 @@ int migr_config(void *data, const char *el) else if (!strcasecmp(el, "c_pop3_fastest")) config.c_pop3_fastest = atol(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "c_spam_flag_only")) config.c_spam_flag_only = atoi(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "c_nntp_port")) config.c_nntp_port = atoi(ChrPtr(migr_chardata)); + else if (!strcasecmp(el, "c_nntps_port")) config.c_nntps_port = atoi(ChrPtr(migr_chardata)); else return 0; return 1; /* Found above...*/ } @@ -654,7 +702,7 @@ int migr_controlrecord(void *data, const char *el) else if (!strcasecmp(el, "control_flags")) CitControl.MMflags = atoi(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "control_nextuser")) CitControl.MMnextuser = atol(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "control_nextroom")) CitControl.MMnextroom = atol(ChrPtr(migr_chardata)); - else if (!strcasecmp(el, "control_version")) CitControl.version = atoi(ChrPtr(migr_chardata)); + else if (!strcasecmp(el, "control_version")) CitControl.MM_hosted_upgrade_level = atoi(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "control")) { CitControl.MMfulltext = (-1L); /* always flush */ @@ -1035,7 +1083,6 @@ CTDL_MODULE_INIT(migrate) if (!threading) { CtdlRegisterProtoHook(cmd_migr, "MIGR", "Across-the-wire migration"); - CtdlRegisterProtoHook(cmd_migr, "ARTV", "Across-the-wire migration (legacy syntax)"); } /* return our module name for the log */