comparison src/plugins/convert/convert-tool.c @ 6976:7cedc391e6c5 HEAD

Convert only after namespaces are created. Convert mailboxes to INBOX namespace.
author Timo Sirainen <tss@iki.fi>
date Sun, 09 Dec 2007 15:47:03 +0200
parents 65c69a53a7be
children 7ed926ed7aa4
comparison
equal deleted inserted replaced
6975:f2c37fe48668 6976:7cedc391e6c5
2 2
3 #include "lib.h" 3 #include "lib.h"
4 #include "ioloop.h" 4 #include "ioloop.h"
5 #include "randgen.h" 5 #include "randgen.h"
6 #include "lib-signals.h" 6 #include "lib-signals.h"
7 #include "mail-storage.h" 7 #include "mail-namespace.h"
8 #include "mail-storage-private.h"
8 #include "convert-storage.h" 9 #include "convert-storage.h"
9 10
10 #include <stdlib.h> 11 #include <stdlib.h>
11 12
12 #define USAGE_STRING \ 13 #define USAGE_STRING \
15 16
16 int main(int argc, const char *argv[]) 17 int main(int argc, const char *argv[])
17 { 18 {
18 struct ioloop *ioloop; 19 struct ioloop *ioloop;
19 struct convert_settings set; 20 struct convert_settings set;
21 struct mail_namespace *dest_ns;
22 enum mail_storage_flags dest_flags;
23 enum file_lock_method lock_method;
24 const char *error;
20 int i, ret = 0; 25 int i, ret = 0;
21 26
22 lib_init(); 27 lib_init();
23 lib_signals_init(); 28 lib_signals_init();
24 random_init(); 29 random_init();
42 set.skip_dotdirs = TRUE; 47 set.skip_dotdirs = TRUE;
43 else if (strncmp(argv[i], "alt_hierarchy_char=", 19) != 0) 48 else if (strncmp(argv[i], "alt_hierarchy_char=", 19) != 0)
44 set.alt_hierarchy_char = argv[i][19]; 49 set.alt_hierarchy_char = argv[i][19];
45 } 50 }
46 51
47 ret = convert_storage(argv[3], argv[4], &set); 52 mail_storage_parse_env(&dest_flags, &lock_method);
53 dest_ns = mail_namespaces_init_empty(pool_datastack_create());
54 if (mail_storage_create(dest_ns, NULL, argv[4], set.user,
55 dest_flags, lock_method, &error) < 0) {
56 i_fatal("Failed to create destination "
57 "mail storage with data '%s': %s", argv[4], error);
58 }
59
60 ret = convert_storage(argv[3], dest_ns, &set);
48 if (ret > 0) 61 if (ret > 0)
49 i_info("Successfully converted"); 62 i_info("Successfully converted");
50 else if (ret == 0) 63 else if (ret == 0)
51 i_error("Source storage not found"); 64 i_error("Source storage not found");
52 else 65 else
53 i_error("Internal failure"); 66 i_error("Internal failure");
67 mail_namespaces_deinit(&dest_ns);
54 68
55 io_loop_destroy(&ioloop); 69 io_loop_destroy(&ioloop);
56 mail_storage_deinit(); 70 mail_storage_deinit();
57 lib_signals_deinit(); 71 lib_signals_deinit();
58 lib_deinit(); 72 lib_deinit();