commit c479813a3665f6bef2fddbed4137f744d192ab38
parent 3c4f6ac66d96e61f34d224cbf6a91ac10196712d
Author: Jacki <jacki@thejackimonster.de>
Date: Sun, 19 Jul 2026 20:36:16 +0200
Add function to stop file upload
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/include/gnunet/gnunet_chat_lib.h b/include/gnunet/gnunet_chat_lib.h
@@ -1773,6 +1773,15 @@ enum GNUNET_GenericReturnValue
GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file);
/**
+ * Stops uploading a file from a given <i>file</i> handle.
+ *
+ * @param[in,out] file File handle
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_CHAT_file_stop_upload (struct GNUNET_CHAT_File *file);
+
+/**
* Returns if a given <i>file</i> handle is currently ready
* for previewing its content.
*
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
@@ -2690,6 +2690,23 @@ GNUNET_CHAT_file_is_uploading (const struct GNUNET_CHAT_File *file)
enum GNUNET_GenericReturnValue
+GNUNET_CHAT_file_stop_upload (struct GNUNET_CHAT_File *file)
+{
+ GNUNET_CHAT_VERSION_ASSERT();
+
+ if (!file)
+ return GNUNET_SYSERR;
+
+ if (!file->publish)
+ return GNUNET_SYSERR;
+
+ GNUNET_FS_publish_stop(file->publish);
+ file->publish = NULL;
+ return GNUNET_OK;
+}
+
+
+enum GNUNET_GenericReturnValue
GNUNET_CHAT_file_is_ready (const struct GNUNET_CHAT_File *file)
{
GNUNET_CHAT_VERSION_ASSERT();
@@ -2894,6 +2911,9 @@ GNUNET_CHAT_file_pause_download (struct GNUNET_CHAT_File *file)
if (!file)
return GNUNET_SYSERR;
+ if (!file->download)
+ return GNUNET_SYSERR;
+
GNUNET_FS_download_suspend(file->download);
return GNUNET_OK;
}
@@ -2907,6 +2927,9 @@ GNUNET_CHAT_file_resume_download (struct GNUNET_CHAT_File *file)
if (!file)
return GNUNET_SYSERR;
+ if (!file->download)
+ return GNUNET_SYSERR;
+
GNUNET_FS_download_resume(file->download);
return GNUNET_OK;
}
@@ -2920,6 +2943,9 @@ GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file)
if (!file)
return GNUNET_SYSERR;
+ if (!file->download)
+ return GNUNET_SYSERR;
+
GNUNET_FS_download_stop(file->download, GNUNET_YES);
file->download = NULL;
return GNUNET_OK;