Implemented a guard against a rare fault condition where the remote server does not send a file size even when requested. eric7

Sat, 05 Oct 2024 13:52:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Oct 2024 13:52:42 +0200
branch
eric7
changeset 10952
b54b3eacfab6
parent 10951
8a7e3a26fe36
child 10953
42166c630d9b

Implemented a guard against a rare fault condition where the remote server does not send a file size even when requested.

src/eric7/QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/src/eric7/QScintilla/Editor.py	Sat Oct 05 11:40:01 2024 +0200
+++ b/src/eric7/QScintilla/Editor.py	Sat Oct 05 13:52:42 2024 +0200
@@ -461,12 +461,16 @@
                 if FileSystemUtilities.isRemoteFileName(self.fileName):
                     fileIsRemote = True
                     fileExists = self.__remotefsInterface.exists(self.fileName)
-                    fileSizeKB = (
-                        self.__remotefsInterface.stat(self.fileName, ["st_size"])[
-                            "st_size"
-                        ]
-                        // 1024
-                    )
+                    try:
+                        fileSizeKB = (
+                            self.__remotefsInterface.stat(self.fileName, ["st_size"])[
+                                "st_size"
+                            ]
+                            // 1024
+                        )
+                    except KeyError:
+                        # should not happen, but play it save
+                        fileSizeKB = 0
                 elif FileSystemUtilities.isDeviceFileName(self.fileName):
                     fileIsRemote = False
                     fileExists = False

eric ide

mercurial