From fe16fd5964ff022781bc01f5c60a74e6e855e237 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 10 Oct 2023 18:56:09 -0400 Subject: [PATCH] move struct uploaded_file to webcit.h --- .gitignore | 2 +- webcit-ng/server/upload.c | 19 ++++++++----------- webcit-ng/server/webcit.h | 8 ++++++++ webcit-ng/static/js/upload.js | 4 ++++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 76aa018d4..bd6ec4f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ *.dsc -*.dsc *.changes *.deb *.tar.gz @@ -10,3 +9,4 @@ tmp webcit_* citadel_* libcitadel_* +.vscode diff --git a/webcit-ng/server/upload.c b/webcit-ng/server/upload.c index 17d96a9a3..110241c3c 100644 --- a/webcit-ng/server/upload.c +++ b/webcit-ng/server/upload.c @@ -7,14 +7,6 @@ #include "webcit.h" -struct uploaded_file { - char id[64]; - char filename[256]; - char content_type[256]; - long length; - FILE *fp; -}; - Array *upload_list = NULL; // all files uploaded to this webcit instance pthread_mutex_t upload_list_mutex = PTHREAD_MUTEX_INITIALIZER; // Lock it before modifying @@ -106,8 +98,8 @@ void ctdl_p_base(struct http_transaction *h, struct ctdlsession *c) { } -// DAV delete an uploaded item -void dav_delete_upload(struct http_transaction *h, struct ctdlsession *c, struct uploaded_file this_one) { +// delete an uploaded item +void delete_upload(struct uploaded_file this_one) { int i; struct uploaded_file *u; @@ -121,7 +113,12 @@ void dav_delete_upload(struct http_transaction *h, struct ctdlsession *c, struct } } pthread_mutex_unlock(&upload_list_mutex); +} + +// DAV delete an uploaded item +void dav_delete_upload(struct http_transaction *h, struct ctdlsession *c, struct uploaded_file this_one) { + delete_upload(this_one); do_204(h); } @@ -187,4 +184,4 @@ void ctdl_p(struct http_transaction *h, struct ctdlsession *c) { // If we get to this point, the client requested an action we don't know how to perform. do_404(h); -} \ No newline at end of file +} diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index a52ac5993..64368b0e5 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -95,6 +95,14 @@ struct ctdlsession { time_t room_mtime; // Timestampt of the most recent write activity in this room }; +struct uploaded_file { // things that have been uploaded to the server (such as email attachments) + char id[64]; + char filename[256]; + char content_type[256]; + long length; + FILE *fp; +}; + extern char *ssl_cipher_list; extern int is_https; // nonzero if we are an HTTPS server today extern char *ctdl_dir; // directory where Citadel Server is running diff --git a/webcit-ng/static/js/upload.js b/webcit-ng/static/js/upload.js index c253471e1..28c374edb 100644 --- a/webcit-ng/static/js/upload.js +++ b/webcit-ng/static/js/upload.js @@ -145,6 +145,10 @@ function show_or_hide_upload_window() { // Flush all uploaded files and close the window function flush_uploads() { document.getElementById('ctdl-upload').style.display='none'; + // FIXME tell the server to delete the files + uploads.forEach(u => { + console.log(u.ref); + }); uploads=[]; } -- 2.30.2