# HG changeset patch # User Goffi # Date 1527253837 -7200 # Node ID 423d462ea739db636887a587bf4b64d0ccdf22c8 # Parent 38b43ed18bb513d8cdef1e19e3470e3bb34da9aa file sharing: catch OS errors while trying to list files on a local dir diff -r 38b43ed18bb5 -r 423d462ea739 cagou/plugins/plugin_wid_file_sharing.py --- 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))