From 620ec005c6c14fe5b08b884d2bf3cbed6b280c89 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Thu, 23 Mar 2023 17:35:27 +0100
Subject: [PATCH] Correct regression in loadscript

---
 src/mio/filecache.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/mio/filecache.py b/src/mio/filecache.py
index f5c79b1..b5bfd4b 100755
--- a/src/mio/filecache.py
+++ b/src/mio/filecache.py
@@ -160,7 +160,7 @@ class FileCache:
         os.chmod(f.name, 0o700)
         return f
 
-    def loadfile(self, path, *name):
+    def loadfile(self, path, *name, mode=None):
         if  not path in self.loader:
             # Create loader for new path
             up = urlparse(path)
@@ -187,6 +187,8 @@ class FileCache:
                 u.close()
                 f.close()
                 os.utime(f.name, (mtime, mtime))
+                if mode != None:
+                    os.chmod(f.name, 0o700)
                 self.cache[key] = CacheEntry(f.name, key)
                 pass
             pass
@@ -244,10 +246,7 @@ expand_mirror = _cache.expand_mirror
 atexit.register(_cache.cleanup)
 
 def loadscript(path, *name):
-    result = loadfile(path, *name)
-    if result.filename in temp:
-        os.chmod(result.filename, 0o700)
-    return result
+    return loadfile(path, *name, mode=0o700)
 
 def localpath(prefix, *path):
     return os.path.normpath('/'.join(filter(None, [prefix] + list(path))))
-- 
GitLab