From: Wilfried Goesgens Date: Sat, 25 Jan 2014 13:03:08 +0000 (+0100) Subject: ATTACHMENTS: hande UID of files on the partnum param on upload. that way fresh &... X-Git-Tag: v9.01~145 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=54a3ac9e8fbc5e533cec6b83c171fa87551b8af4 ATTACHMENTS: hande UID of files on the partnum param on upload. that way fresh & forwarded attachment are instantly addressable via a uniq identifier. --- diff --git a/webcit/messages.c b/webcit/messages.c index 29fd30559..fd886f415 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1234,6 +1234,7 @@ void upload_attachment(void) { wc_mime_attachment *att; const StrBuf *Tmpl = sbstr("template"); const StrBuf *MimeType = NULL; + const StrBuf *UID; begin_burst(); syslog(LOG_DEBUG, "upload_attachment()\n"); @@ -1248,7 +1249,7 @@ void upload_attachment(void) { } else wc_printf("ERROR no attachment was uploaded
\n"); http_transmit_thing(ChrPtr(MimeType), 0); - + return; } @@ -1261,7 +1262,10 @@ void upload_attachment(void) { att->length = WCC->upload_length; att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1); att->FileName = NewStrBufDup(WCC->upload_filename); - + UID = SBSTR("qquuid"); + if (UID) + att->PartNum = NewStrBufDup(UID); + if (WCC->attachments == NULL) { WCC->attachments = NewHash(1, Flathash); } @@ -1315,26 +1319,35 @@ void remove_attachment(void) { StrBuf *WhichAttachment; HashPos *at; long len; + int found=0; const char *key; WhichAttachment = NewStrBufDup(sbstr("which_attachment")); + if (ChrPtr(WhichAttachment)[0] == '/') + StrBufCutLeft(WhichAttachment, 1); StrBufUnescape(WhichAttachment, 0); at = GetNewHashPos(WCC->attachments, 0); do { + vAtt = NULL; GetHashPos(WCC->attachments, at, &len, &key, &vAtt); - + att = (wc_mime_attachment*) vAtt; - if ((att != NULL) && - (strcmp(ChrPtr(WhichAttachment), - ChrPtr(att->FileName) ) == 0)) + if ((att != NULL) && + ( + !strcmp(ChrPtr(WhichAttachment), ChrPtr(att->FileName)) || + ((att->PartNum != NULL) && + !strcmp(ChrPtr(WhichAttachment), ChrPtr(att->PartNum))) + )) { DeleteEntryFromHash(WCC->attachments, at); + found=1; break; } } while (NextHashPos(WCC->attachments, at)); + FreeStrBuf(&WhichAttachment); - wc_printf("remove_attachment() completed\n"); + wc_printf("remove_attachment(%d) completed\n", found); }