Check modified dates against a server's files

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Check modified dates against a server's files

Post by LunaRebirth »

I have a program which sends it's file modified times in a directory to the server.
If the client modified times do not match the server's file times, the server sends the files to the client, ensuring that everyone gets the most up-to-date files (like images and models) and that they cannot edit them without uploading it to the server first.

This works fine, but if I package my program in a .zip file and send it to someone, the modified timestamps change to the current local time, so when they open the app, my server thinks all of the files are outdated.

What's the best approach to handle modified dates for this?

I tried making a .txt file that stores all dates of the files, and checking modification based on the text file, but it'd be super easy for someone to edit the .txt file to trick the server.
MartinVee
Posts: 139
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: Check modified dates against a server's files

Post by MartinVee »

You should send the hash of the files instead of modification timestamps as these can be tampared as easily as a TXT file.

When you start your program, hash all the files (I'd suggest SHA or MD5 to avoid collisions), send all the hashes to the server, the server then compares the received hashes with the server's hashes, and send back only the files that don't match.

This has the added benefit of correcting an file corruption on the client's side. For extra performance, on the server side, re-hash only the files when they're updated. On the client side, though, re-hash each time.
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Check modified dates against a server's files

Post by LunaRebirth »

Okay that's a much better solution than what I was doing.
Thanks!
Post Reply