From 62fcb3760660d1fb1af0cb6dea001afd278b0228 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Fri, 2 Jul 2021 10:37:15 +0200 Subject: [PATCH] Get server_id from piler_id for utilities Signed-off-by: Janos SUTO --- src/archive.c | 4 ++-- src/pileraget.c | 2 +- util/pilerpurge.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/archive.c b/src/archive.c index 97e5a376..60ca6320 100644 --- a/src/archive.c +++ b/src/archive.c @@ -277,7 +277,7 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct c return 1; } - snprintf(filename, sizeof(filename)-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.m", cfg->queuedir, cfg->server_id, *(sdata->ttmpfile+8), *(sdata->ttmpfile+9), *(sdata->ttmpfile+10), *(sdata->ttmpfile+RND_STR_LEN-4), *(sdata->ttmpfile+RND_STR_LEN-3), *(sdata->ttmpfile+RND_STR_LEN-2), *(sdata->ttmpfile+RND_STR_LEN-1), sdata->ttmpfile); + snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c%c/%c%c/%c%c/%s.m", cfg->queuedir, *(sdata->ttmpfile+24), *(sdata->ttmpfile+25), *(sdata->ttmpfile+8), *(sdata->ttmpfile+9), *(sdata->ttmpfile+10), *(sdata->ttmpfile+RND_STR_LEN-4), *(sdata->ttmpfile+RND_STR_LEN-3), *(sdata->ttmpfile+RND_STR_LEN-2), *(sdata->ttmpfile+RND_STR_LEN-1), sdata->ttmpfile); #ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT if(stat(filename, &st)){ snprintf(filename, sizeof(filename)-1, "%s/%02x/%c%c/%c%c/%c%c/%s.m", cfg->queuedir, cfg->server_id, *(sdata->ttmpfile+RND_STR_LEN-6), *(sdata->ttmpfile+RND_STR_LEN-5), *(sdata->ttmpfile+RND_STR_LEN-4), *(sdata->ttmpfile+RND_STR_LEN-3), *(sdata->ttmpfile+RND_STR_LEN-2), *(sdata->ttmpfile+RND_STR_LEN-1), sdata->ttmpfile); @@ -304,7 +304,7 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct c buffer = p + strlen(pointer); if(strlen(ptr_arr[i].piler_id) == RND_STR_LEN){ - snprintf(filename, sizeof(filename)-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, cfg->server_id, ptr_arr[i].piler_id[8], ptr_arr[i].piler_id[9], ptr_arr[i].piler_id[10], ptr_arr[i].piler_id[RND_STR_LEN-4], ptr_arr[i].piler_id[RND_STR_LEN-3], ptr_arr[i].piler_id[RND_STR_LEN-2], ptr_arr[i].piler_id[RND_STR_LEN-1], ptr_arr[i].piler_id, ptr_arr[i].attachment_id); + snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, ptr_arr[i].piler_id[24], ptr_arr[i].piler_id[25], ptr_arr[i].piler_id[8], ptr_arr[i].piler_id[9], ptr_arr[i].piler_id[10], ptr_arr[i].piler_id[RND_STR_LEN-4], ptr_arr[i].piler_id[RND_STR_LEN-3], ptr_arr[i].piler_id[RND_STR_LEN-2], ptr_arr[i].piler_id[RND_STR_LEN-1], ptr_arr[i].piler_id, ptr_arr[i].attachment_id); #ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT if(stat(filename, &st)){ diff --git a/src/pileraget.c b/src/pileraget.c index 3b780cc5..90f6aa33 100644 --- a/src/pileraget.c +++ b/src/pileraget.c @@ -46,7 +46,7 @@ int main(int argc, char **argv){ return 1; } - snprintf(filename, sizeof(filename)-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.a%d", cfg.queuedir, cfg.server_id, argv[1][8], argv[1][9], argv[1][10], argv[1][RND_STR_LEN-4], argv[1][RND_STR_LEN-3], argv[1][RND_STR_LEN-2], argv[1][RND_STR_LEN-1], argv[1], atoi(argv[2])); + snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c%c/%c%c/%c%c/%s.a%d", cfg.queuedir, argv[1][24], argv[1][25], argv[1][8], argv[1][9], argv[1][10], argv[1][RND_STR_LEN-4], argv[1][RND_STR_LEN-3], argv[1][RND_STR_LEN-2], argv[1][RND_STR_LEN-1], argv[1], atoi(argv[2])); #ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT if(stat(filename, &st)){ snprintf(filename, sizeof(filename)-1, "%s/%02x/%c%c/%c%c/%c%c/%s.a%d", cfg.queuedir, cfg.server_id, argv[1][RND_STR_LEN-6], argv[1][RND_STR_LEN-5], argv[1][RND_STR_LEN-4], argv[1][RND_STR_LEN-3], argv[1][RND_STR_LEN-2], argv[1][RND_STR_LEN-1], argv[1], atoi(argv[2])); diff --git a/util/pilerpurge.py b/util/pilerpurge.py index 3239cd1a..cca0119f 100755 --- a/util/pilerpurge.py +++ b/util/pilerpurge.py @@ -160,12 +160,12 @@ def unlink(filename="", opts={}): def get_m_file_path(id='', opts={}): - return "/".join([opts['storedir'], opts['server_id'], id[8:11], id[32:34], + return "/".join([opts['storedir'], id[24:26], id[8:11], id[32:34], id[34:36], id + ".m"]) def get_attachment_file_path(piler_id='', attachment_id=0, opts={}): - return "/".join([opts['storedir'], opts['server_id'], piler_id[8:11], + return "/".join([opts['storedir'], piler_id[24:26], piler_id[8:11], piler_id[32:34], piler_id[34:36], piler_id + ".a" + str(attachment_id)])