From 5e63938b0f5479f9a8225f9ba1c74d2846225235 Mon Sep 17 00:00:00 2001
From: "jonathan.ehret" <ehret@vr.rwth-aachen.de>
Date: Wed, 28 Jun 2023 16:57:08 +0200
Subject: [PATCH] fix checking for last modification time

---
 LaunchScript/VirtualAcousticsStarterServer.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/LaunchScript/VirtualAcousticsStarterServer.py b/LaunchScript/VirtualAcousticsStarterServer.py
index 155ad34..7f46794 100644
--- a/LaunchScript/VirtualAcousticsStarterServer.py
+++ b/LaunchScript/VirtualAcousticsStarterServer.py
@@ -418,14 +418,16 @@ class VirtualAcousticsLauncher:
     Fullpath = os.path.join(self.sCurrentScriptsDirectory, "..", "tmp", ProjectName, Path, "")
     print("Should receive file: "+Filename+" in path "+Fullpath+ " with "+str(iBytesToReceive)+" bytes")
 
-    iLocalFileLastModification = os.path.getmtime(Fullpath+Filename)
+    iLocalFileLastModification = iLastModificationTime # default set it to the remote file time (in case it does not exist yet)
+    if os.path.isfile(Fullpath+Filename):
+      iLocalFileLastModification = os.path.getmtime(Fullpath+Filename)
 
     #check whether the file with this exact size (which is not older than the file to send) already exists
-    if os.path.isfile(Fullpath+Filename) and os.stat(Fullpath+Filename).st_size==iBytesToReceive and iLocalFileLastModification<iLastModificationTime:
+    if os.path.isfile(Fullpath+Filename) and os.stat(Fullpath+Filename).st_size==iBytesToReceive and iLocalFileLastModification>iLastModificationTime:
       self.oLauncherConnection.send( b'exists' )
       print("File already exists with this size, so no need for resending")
 
-    else: #file need to be received
+    else: #file needs to be received
       #create dir if it does not exist
       if not os.path.exists(Fullpath):
         os.makedirs(Fullpath)
-- 
GitLab