diff --git a/etc/example.conf b/etc/example.conf index c002a15..853d8b5 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -34,6 +34,14 @@ ; which will cause problems. encrypt_messages=1 +; If the previous 3 letter store top directories, eg. /var/piler/store/00/5f4 +; are consolidated (1) to a single zip file or not (0). +; Eg. cd /var/piler/store/00 +; zip -r -0 5f3.zip 5f3 +; After the consolidation (ie. zipping the given directory) piler tries to +; read the given file from the appropriate zip file. +consolidated_store=0 + ; number of worker processes, ie. the number of simultaneous smtp connections to piler. ; This value should be the number of cpus + 1, ie. 2 for a single cpu host number_of_worker_processes=2 diff --git a/src/archive.c b/src/archive.c index 237ae75..45d894d 100644 --- a/src/archive.c +++ b/src/archive.c @@ -300,12 +300,14 @@ char zipfilename[SMALLBUFSIZE]; struct stat st; - /* - * If the zip file exists, then fix the filename to be ' ' - */ snprintf(zipfilename, sizeof(zipfilename)-1, "%s/%02x/%c%c%c.zip", cfg->queuedir, cfg->server_id, s[8], s[9], s[10]); - if(stat(zipfilename, &st)){ + if(cfg->consolidated_store == 1 && stat(zipfilename, &st) == 0){ + // If the zip file exists, then fix the filename to be ' ' + snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.m", + zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s); + } + else { snprintf(filename, len-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.m", cfg->queuedir, cfg->server_id, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s); #ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT @@ -314,9 +316,6 @@ cfg->queuedir, cfg->server_id, s[RND_STR_LEN-6], s[RND_STR_LEN-5], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s); } #endif - } else { - snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.m", - zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s); } } @@ -327,7 +326,11 @@ snprintf(zipfilename, sizeof(zipfilename)-1, "%s/%02x/%c%c%c.zip", cfg->queuedir, cfg->server_id, s[8], s[9], s[10]); - if(stat(zipfilename, &st)){ + if(cfg->consolidated_store == 1 && stat(zipfilename, &st) == 0){ + snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.a%d", + zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id); + } + else { snprintf(filename, len-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, cfg->server_id, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id); #ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT @@ -336,9 +339,6 @@ cfg->queuedir, cfg->server_id, s[RND_STR_LEN-6], s[RND_STR_LEN-5], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id); } #endif - } else { - snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.a%d", - zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id); } } diff --git a/src/cfg.c b/src/cfg.c index 0c40b70..8143abf 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -48,6 +48,7 @@ { "clamd_addr", "string", (void*) string_parser, offsetof(struct config, clamd_addr), "", MAXVAL-1}, { "clamd_port", "integer", (void*) int_parser, offsetof(struct config, clamd_port), "0", sizeof(int)}, { "clamd_socket", "string", (void*) string_parser, offsetof(struct config, clamd_socket), CLAMD_SOCKET, MAXVAL-1}, + { "consolidated_store", "integer", (void*) int_parser, offsetof(struct config, consolidated_store), "0", sizeof(int)}, { "debug", "integer", (void*) int_parser, offsetof(struct config, debug), "0", sizeof(int)}, { "default_retention_days", "integer", (void*) int_parser, offsetof(struct config, default_retention_days), "2557", sizeof(int)}, { "enable_chunking", "integer", (void*) int_parser, offsetof(struct config, enable_chunking), "0", sizeof(int)}, diff --git a/src/cfg.h b/src/cfg.h index 03ea7d1..4019b83 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -23,6 +23,8 @@ int clamd_port; char clamd_socket[MAXVAL]; + int consolidated_store; + int encrypt_messages; int enable_chunking;