Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #449 from ltworf/sendfilecrash
Browse files Browse the repository at this point in the history
Fix crash when sending non existing file
  • Loading branch information
ltworf authored Jan 29, 2024
2 parents 12ea760 + 5e4a41f commit 9ec3ff3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.25
* Fix crash when sending a non existing file

1.24
* Add /dropautoreact command
* Add /listautoreact command
Expand Down
10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
localslackirc (1.24-1) UNRELEASED; urgency=medium
localslackirc (1.25-1) UNRELEASED; urgency=medium

* New upstream release

-- Salvo 'LtWorf' Tomaselli <[email protected]> Mon, 20 Nov 2023 20:06:54 +0100
-- Salvo 'LtWorf' Tomaselli <[email protected]> Mon, 29 Jan 2024 16:08:41 +0100

localslackirc (1.24-1) unstable; urgency=low

* New upstream release

-- Salvo 'LtWorf' Tomaselli <[email protected]> Sat, 02 Dec 2023 16:46:36 +0100

localslackirc (1.23-1) unstable; urgency=low

Expand Down
13 changes: 8 additions & 5 deletions irc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# localslackirc
# Copyright (C) 2018-2023 Salvo "LtWorf" Tomaselli
# Copyright (C) 2018-2024 Salvo "LtWorf" Tomaselli
#
# localslackirc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -40,7 +40,7 @@
from diff import seddiff


VERSION = '1.24'
VERSION = '1.25'


class IrcDisconnectError(Exception): ...
Expand Down Expand Up @@ -432,9 +432,12 @@ async def _sendfilehandler(self, cmd: bytes) -> None:
await self._sendreply(Replies.ERR_UNKNOWNCOMMAND, 'Syntax: /sendfile #channel filename')
return

with open(filename, 'rb') as f:
content = f.read()
await self.send_file(params[1], content=content, filename=filename)
try:
with open(filename, 'rb') as f:
content = f.read()
await self.send_file(params[1], content=content, filename=filename)
except Exception as e:
await self._sendreply(Replies.ERR_FILEERROR, f'Error: {e}')


async def send_file(self, bchannel_name: bytes, content: bytes, filename: str) -> bool:
Expand Down

0 comments on commit 9ec3ff3

Please sign in to comment.