Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_file_sharing.py @ 213:423d462ea739
file sharing: catch OS errors while trying to list files on a local dir
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 25 May 2018 15:10:37 +0200 |
parents | 38b43ed18bb5 |
children | 6a98d70a3a66 |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_file_sharing.py Fri May 25 14:59:52 2018 +0200 +++ b/cagou/plugins/plugin_wid_file_sharing.py Fri May 25 15:10:37 2018 +0200 @@ -390,7 +390,18 @@ if self.mode == MODE_LOCAL: filepath = os.path.join(self.local_dir, u'..') self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath)) - files = sorted(os.listdir(self.local_dir)) + try: + files = sorted(os.listdir(self.local_dir)) + except OSError as e: + msg = _(u"can't list files in \"{local_dir}\": {msg}").format( + local_dir=self.local_dir, + msg=e) + G.host.addNote( + _(u"shared folder error"), + msg, + level=C.XMLUI_DATA_LVL_WARNING) + self.local_dir = expanduser(u'~') + return for f in files: filepath = os.path.join(self.local_dir, f) self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath))