X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fmigrate%2Fserv_migrate.c;h=aad6615f553dce0659d0f3954edbbd6810411f6d;hb=0fcfc4d81b4def0bd0f7562465b5bf7ef4b7857b;hp=f6d705568d691fc52d8f27f4dea8c610c44d0396;hpb=e830265f9a3238898ea25e8ed4782e50f2b7a775;p=citadel.git diff --git a/citadel/modules/migrate/serv_migrate.c b/citadel/modules/migrate/serv_migrate.c index f6d705568..aad6615f5 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-2020 by the citadel.org team + * Copyright (c) 1987-2021 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. @@ -34,18 +34,7 @@ #include #include #include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - +#include #include #include #include @@ -63,15 +52,12 @@ #include "euidindex.h" #include "ctdl_module.h" -#define END_OF_MESSAGE "---eom---dbd---" - char migr_tempfilename1[PATH_MAX]; char migr_tempfilename2[PATH_MAX]; FILE *migr_global_message_list; int total_msgs = 0; char *ikey = NULL; // If we're importing a config key we store it here. - /****************************************************************************** * Code which implements the export appears in this section * ******************************************************************************/ @@ -137,6 +123,7 @@ void migr_export_users_backend(char *username, void *data) { cprintf("%ld\n", u.msgnum_pic); cprintf("%s\n", u.emailaddrs); cprintf("%ld\n", u.msgnum_inboxrules); + cprintf("%ld\n", u.lastproc_inboxrules); client_write(HKEY("\n")); } @@ -328,7 +315,7 @@ void migr_export_message(long msgnum) { /* Ok, here we go ... */ - msg = CtdlFetchMessage(msgnum, 1, 0); + msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) return; /* fail silently */ client_write(HKEY("\n")); @@ -476,8 +463,8 @@ void migr_do_export(void) { if (Ctx->kill_me == 0) migr_export_visits(); cprintf("%d\n", 25); if (Ctx->kill_me == 0) migr_export_messages(); - client_write(HKEY("\n")); cprintf("%d\n", 100); + client_write(HKEY("\n")); client_write(HKEY("000\n")); Ctx->dont_term = 0; } @@ -590,6 +577,7 @@ int migr_userrecord(void *data, const char *el) else if (!strcasecmp(el, "u_msgnum_pic")) usbuf.msgnum_pic = atol(ChrPtr(migr_chardata)); else if (!strcasecmp(el, "u_emailaddrs")) safestrncpy(usbuf.emailaddrs, ChrPtr(migr_chardata), sizeof usbuf.emailaddrs); else if (!strcasecmp(el, "u_msgnum_inboxrules")) usbuf.msgnum_inboxrules = atol(ChrPtr(migr_chardata)); + else if (!strcasecmp(el, "u_lastproc_inboxrules")) usbuf.lastproc_inboxrules = atol(ChrPtr(migr_chardata)); else return 0; return 1; } @@ -846,14 +834,12 @@ void migr_xml_end(void *data, const char *el) * Import begins here */ void migr_do_import(void) { - StrBuf *Buf; XML_Parser xp; - int Finished = 0; + char buf[SIZ]; unbuffer_output(); migr_chardata = NewStrBufPlain(NULL, SIZ * 20); migr_MsgData = NewStrBufPlain(NULL, SIZ * 20); - Buf = NewStrBufPlain(NULL, SIZ); xp = XML_ParserCreate(NULL); if (!xp) { cprintf("%d Failed to create XML parser instance\n", ERROR+INTERNAL_ERROR); @@ -869,24 +855,14 @@ void migr_do_import(void) { client_set_inbound_buf(SIZ * 10); - while (!Finished && client_read_random_blob(Buf, -1) >= 0) { - if ((StrLength(Buf) > 4) && !strcmp(ChrPtr(Buf) + StrLength(Buf) - 4, "000\n")) { - Finished = 1; - StrBufCutAt(Buf, StrLength(Buf) - 4, NULL); - } + while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) { + XML_Parse(xp, buf, strlen(buf), 0); if (server_shutting_down) break; // Should we break or return? - - if (StrLength(Buf) == 0) - continue; - - XML_Parse(xp, ChrPtr(Buf), StrLength(Buf), 0); - FlushStrBuf(Buf); } XML_Parse(xp, "", 0, 1); XML_ParserFree(xp); - FreeStrBuf(&Buf); FreeStrBuf(&migr_chardata); FreeStrBuf(&migr_MsgData); rebuild_euid_index(); @@ -920,7 +896,6 @@ HashList *UsedMessageIDS = NULL; int migr_restore_message_metadata(long msgnum, int refcount) { - CitContext *CCC = MyContext(); struct MetaData smi; struct CtdlMessage *msg; char *mptr = NULL; @@ -949,7 +924,7 @@ int migr_restore_message_metadata(long msgnum, int refcount) /* Ok, here we go ... */ - msg = CtdlFetchMessage(msgnum, 1, 0); + msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) { return 1; } @@ -976,10 +951,10 @@ int migr_restore_message_metadata(long msgnum, int refcount) } } - CCC->redirect_buffer = PlainMessageBuf; + CC->redirect_buffer = PlainMessageBuf; CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, QP_EADDR); - smi.meta_rfc822_length = StrLength(CCC->redirect_buffer); - CCC->redirect_buffer = NULL; + smi.meta_rfc822_length = StrLength(CC->redirect_buffer); + CC->redirect_buffer = NULL; syslog(LOG_INFO, "Setting message #%ld meta data to: refcount=%d, bodylength=%ld, content-type: %s",