Daylight Savings Time FAT32 Fix

Know of something that might be useful to the DC community? Post it here! (Still, no advertising)

Moderator: Moderators

Locked
lordadmira
Posts: 52
Joined: 2003-03-12 00:06
Location: Zinzinnati

Daylight Savings Time FAT32 Fix

Post by lordadmira » 2006-11-22 05:45

This is a repost of the original post that seems to have vanished. I'm reposting it for the benefit of those who have FAT32 shares on Windows 2000. When daylight savings time comes on or off, DC++ will rehash that entire drive because of the way the system presents times from said disks.

For the record, when daylight savings time ends, do DSTfix.pl forward. When it starts do DSTfix.pl back.

=Begin repost===
Ok I've got the script working. It's in Perl which can be downloaded from ActiveState if u don't have it. The script is easy to use. I built in error checking at every step of the way so there should be no way for anything bad to happen.

It works by reading in each line from HashIndex.xml and adding or subtracting 3600 from the timestamp field of files on the drives in question. It checks for HashIndex.xml and HashData.dat in the current directory. Checks for the presence of backup files and won't overwrite them; it makes backups so the old xml's can be restored. Checks to see if DC++ is running and won't run if it is. Checks for valid command line arguments. Checks for sufficient free space to write the new file and make backups.
It prints extensive help info with the -h command line parameter.

Code: Select all

Examples:
  perl DSTfix.pl c: f: forward
    Changes the time stamps of files on the C: and F: drives forward 1 hour.
  perl DSTfix.pl D Back
    Changes the time stamps of files on the D: drive backwards 1 hour.
I made the arguments as lax as possible. So c = C:, back = BAck, etc.

I successfully tested it with my own DC, .688, and Windows 2000. I turned off daylight savings time and did "perl \DSTfix.pl e forward" and restarted DC++ and it didn't try to rehash anything. But I'm not totally sure what Windows is doing in the background. Windows Explorer changes the time displayed for a file when u turn daylight savings time on or off (FAT32 disk), but, once u refresh the window it shows the old time again. Apparently it's compensating for the time change. So that leaves me wondering which value was the true time on the disk. Even though I disabled daylight savings time, theoretically causing all the times to be 1 hour earlier, I had to specify "forward" to the script to make DC not rehash everything. For example, a file which was hashed while daylight savings time was on had a timestamp of 1070422934 which is Tue Dec 2 22:42:14 2003. I then turned daylight savings time off which "should" have made everything "be" an hour earlier. Indeed Windows Explorer showed a time 1 hour earlier once I made the change but then showed the old time when I hit F5. Yet the post-fix timestamp that DC is happy with is 1070426534 or Tue Dec 2 23:42:14 2003. Turning off daylight time made everything "be" an hour later. If I shifted backwards DC wanted to rehash everything. Maybe it has to do with whether daylight time was on or off when the file was made, or maybe u have to reboot to see the change. Either way we might have to wait 7 months to see which direction u really have to switch it. I was never good with time zones. But be it forward or back, the script does work and the worst case is that u have to run it twice to get it right.

It uses WMI to check for DC++ and free space. That isn't available on non-NT so that part is skipped if it's running on a non-NT operating system. But why would u run this on W95? But somebody'll probably try it so better to handle it now. This will also work on any DC variant that uses the same xml file format. As long as it has "File Name="<letter>" and "TimeStamp="<something>"" it will work. As an undocumented feature I included the ability to shift the timestamp an abitrary amount. Instead of forward or back u can put any real number and it will shift that many hours. So +1, -1.5, +2 are all valid. Maybe ur moving to a new timezone, I don't know. I haven't heard of whole timezones being a problem.

So that's the script. I need some people to try it out and give me feedback. If u can think of a way to "really" test the daylight savings time change go for it. U can get it from my website. Needless to say, backup ur entire DC++ directory before experimenting. It's easy to forget what is what and delete the wrong files.

Then *before* the next time change we need to really get the word out.


LA
Anata ga baka da! Repent!

lordadmira
Posts: 52
Joined: 2003-03-12 00:06
Location: Zinzinnati

Post by lordadmira » 2006-11-22 06:03

I located the original thread in the Google cache and saved it off here http://w3.goodnews.net/~wagnerc/DC++DST/time change causes dc++ 674 to rehash files.htm.
Anata ga baka da! Repent!

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Re: Daylight Savings Time FAT32 Fix

Post by GargoyleMT » 2006-12-06 18:59

lordadmira wrote:This is a repost of the original post that seems to have vanished.
Judging from the date and the forum on the cached entry, it was affected by the 2 week life on posts in Support. No other forums have purging enabled, so it's safe here.

Locked