diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-09-08 13:06:28 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-09-08 13:06:28 +0200 |
commit | 46b76af6456dd448b1b985400e847e564197dfa6 (patch) | |
tree | ae7c670c2a32add3ebfa33a9d283d048a7adb385 /src/plugins/xfer/xfer-network.c | |
parent | b30b492e66b9c4d2cfbc5406933fc95eb61db828 (diff) | |
download | weechat-46b76af6456dd448b1b985400e847e564197dfa6.zip |
xfer: display an error message when opening file for read or write fails (issue #2010)
Diffstat (limited to 'src/plugins/xfer/xfer-network.c')
-rw-r--r-- | src/plugins/xfer/xfer-network.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c index d69c43cf1..4e1e13e0a 100644 --- a/src/plugins/xfer/xfer-network.c +++ b/src/plugins/xfer/xfer-network.c @@ -331,6 +331,18 @@ xfer_network_send_file_fork (struct t_xfer *xfer) xfer->file = open (xfer->local_filename, O_RDONLY | O_NONBLOCK, 0644); + if (xfer->file < 0) + { + weechat_printf (NULL, + _("%s%s: unable to read file \"%s\": %s"), + weechat_prefix ("error"), + XFER_PLUGIN_NAME, + xfer->local_filename, + strerror (errno)); + xfer_close (xfer, XFER_STATUS_FAILED); + xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); + } + switch (pid = fork ()) { case -1: /* fork failed */ @@ -408,6 +420,19 @@ xfer_network_recv_file_fork (struct t_xfer *xfer) 0644); } + if (xfer->file < 0) + { + weechat_printf (NULL, + _("%s%s: unable to write file \"%s\": %s"), + weechat_prefix ("error"), + XFER_PLUGIN_NAME, + xfer->temp_local_filename, + strerror (errno)); + xfer_close (xfer, XFER_STATUS_FAILED); + xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); + return; + } + switch (pid = fork ()) { case -1: /* fork failed */ @@ -872,11 +897,10 @@ xfer_network_connect_init (struct t_xfer *xfer) } else { + xfer->status = XFER_STATUS_CONNECTING; /* for a file: launch child process */ if (XFER_IS_FILE(xfer->type) && XFER_IS_ACTIVE(xfer->type)) xfer_network_recv_file_fork (xfer); - - xfer->status = XFER_STATUS_CONNECTING; } xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); } |