From 01ba1a5c24a508b8f1f04834c0126ca5e4c9aabb Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Fri, 26 May 2006 14:21:00 +0000 Subject: [PATCH] check if we have perms to store the file --- src/filetransfers_window.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 8f672f446..0abe47dfb 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -313,6 +313,12 @@ _('Connection with peer cannot be established.')) file_path = gtkgui_helpers.decode_filechooser_file_paths( (file_path,))[0] if os.path.exists(file_path): + # check if we have write permissions + if not os.access(file_path, os.W_OK): + file_name = os.path.basename(file_path) + dialogs.ErrorDialog(_('Cannot overwrite existing file "%s"' % file_name), + _('A file with this name already exists and you do not have permission to overwrite it.')) + return stat = os.stat(file_path) dl_size = stat.st_size file_size = file_props['size'] @@ -327,6 +333,11 @@ _('Connection with peer cannot be established.')) return elif response == 100: file_props['offset'] = dl_size + else: + dirname = os.path.dirname(file_path) + if not os.access(dirname, os.W_OK): + dialogs.ErrorDialog(_('Directory "%s" is not writable' % dirname), _('You do not have permission to create files in this directory.')) + return dialog2.destroy() self._start_receive(file_path, account, contact, file_props)