From 5b5811bfb469817c1e894b245ef7e030ff044c66 Mon Sep 17 00:00:00 2001
From: vr-group <account@vr.rwth-aachen.de>
Date: Wed, 28 Jun 2023 15:10:17 +0200
Subject: [PATCH] check for modification time when sending files

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

diff --git a/LaunchScript/VirtualAcousticsStarterServer.py b/LaunchScript/VirtualAcousticsStarterServer.py
index 0784648..e47dc3a 100644
--- a/LaunchScript/VirtualAcousticsStarterServer.py
+++ b/LaunchScript/VirtualAcousticsStarterServer.py
@@ -408,16 +408,20 @@ class VirtualAcousticsLauncher:
 
   # Receives a file from a client, copies it to a tmp folder and returns the respective fullpath
   #   Input is a string message starting with "file:"
+  #   it has the content file:[RelativePathToFile]:[FileLengthInBytes]:[ModificationTimeInSecondsSinceEPOCH]
   def receive_file(self, sMessage):
     aMessageParts = sMessage.split(":")
     iBytesToReceive = int(aMessageParts[2])
+    iLastModificationTime = int(aMessageParts[3])
     Path, Filename = os.path.split(aMessageParts[1])
     ProjectName = aMessageParts[3]
     Fullpath = os.path.join(self.sCurrentScriptsDirectory, "..", "tmp", ProjectName, Path, "")
     print("Should receive file: "+Filename+" in path "+Fullpath+ " with "+str(iBytesToReceive)+" bytes")
 
-    #check whether the file with this exact size already exists
-    if os.path.isfile(Fullpath+Filename) and os.stat(Fullpath+Filename).st_size==iBytesToReceive:
+    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:
       self.oLauncherConnection.send( b'exists' )
       print("File already exists with this size, so no need for resending")
 
-- 
GitLab