Skip to content
Snippets Groups Projects
Commit 5b5811bf authored by vr-group's avatar vr-group
Browse files

check for modification time when sending files

parent 2af4f3e3
Branches
No related tags found
No related merge requests found
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment