mIRC Home    About    Download    Register    News    Help

Print Thread
#261645 05/11/17 08:16 PM
Joined: Aug 2015
Posts: 70
Babel fish
OP Offline
Babel fish
Joined: Aug 2015
Posts: 70
For no reason, mIRC asks me to re-load all the scripts i have loaded (when i didnt change anything).

Also, "mirc255571.tm_" mysterious files found in mIRC root directory (i'm using mIRC 7.51).


mIRC Scripts IRC Network: irc://irc.mircscripts.info/chat
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
it's not "no reason" it was because daylight saving time changes the timestamp of files by -1 hour. You can recreate this by using a 'touch' utility to change the timestamp on any of your scripts or ini's.

In remote editor, if you uncheck options/"monitor file changes" you won't see that.

As for the tm_ that is unrelated. That is a temporary filename that mirc uses to make file changes, then replaces on top of the original file.

Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
I have an autoreload script which will reload scripts without a prompt if the timestamp changes - happy to share if anyone is interested.

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Quote:
it's not "no reason"
a change in 'last modified time' does not equal a change in file, technically speaking users are completely right and you're completely wrong.

This issue has been reported before, mIRC does not use a hashing algorithm to make sure the file changed.
The reason for this was that because it takes time to calculate such hashes, and that mIRC might be checking a lot of files, so it would prevent a possible slowdown in this case.

To me this feature is just broken as it does not check file for change but claims there is a change in file when there's only a change in "last time modification'.
I, like a huge number of people, got tired of getting the warning (15 scripts loaded usually means you get 15 prompts whenever this is happening, sorry but no thanks) and just disabled the feature, it's possible to write a script which use an hashing algorithm.

@Protopia: if you are talking about looping on $script and using /reload, that's not going to be helpful because the events which are causing all of this are unknown

Last edited by Wims; 06/11/17 02:18 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Actually now you mention it my script uses hashes.

I wrote it so I could use notepad++ as my script editor.

Last edited by Protopia; 06/11/17 02:19 PM.
Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Yeah? So what's the script and when are you executing it?
The only way to use an external editor correctly while keeping the monitor files option is to use an external editor which communicates with mIRC and which sends /reload when saving file (mIRC close the warning dialog if /reload is received for that file).
I fail to see how you can use notepad++ correctly while keeping to monitor the script files without having to execute /reload manually whenever you save


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
The script checks the hash of every loaded script file every 5 secs and reloads it if it has changed.

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Ok, well that's a terrible workaround!


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Originally Posted By: Wims
Ok, well that's a terrible workaround!

Well:
a. It works
b. It uses very little CPU or disk - because I measured it.

So it may not be as nice as having Windows call mIRC when it changes, or even mIRC having functionality to request this and trigger a signal, but it works exceptionally well.

Last edited by Protopia; 06/11/17 03:04 PM.
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Originally Posted By: Wims
a change in 'last modified time' does not equal a change in file

Moreover, the scripts are not actually being modified, or if they are, they shouldn't be. That is: if the files' last-modified time changes, that would mean that mIRC erroneously modifies them as a result of the time shift. If the files' last-modified time does not change, then mIRC is drawing the wrong conclusion based on the time shift. Either way, it is a bug in mIRC.

It's an ancient one, too, but a fix would still be much appreciated. Hashing the files should not be a required part of any solution, either (although doing so may be beneficial in some other use cases).

Originally Posted By: Wims
(15 scripts loaded usually means you get 15 prompts whenever this is happening, sorry but no thanks)

Just FWIW: it is possible to hold the Esc key to get rid of them all in one go (after all, the files haven't actually changed).

Last edited by Sat; 06/11/17 05:35 PM. Reason: elaborate a bit

Saturn, QuakeNet staff
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Quote:
a change in 'last modified time' does not equal a change in file, technically speaking users are completely right and you're completely wrong.


I'm wrong, but I'm not completely wrong. It's not a change in file contents, but it is a change in the timestamp attribute of the file. It's dumb, but it's still a change in the non-content portion of the file.

A better way to implement it, and one that mIRC should do, is have a 2-step check system. mIRC could store the timestamp of the file like it currently does - but should also record the filesize and the hash of the file at that time. Then mIRC should check to see if the timestamp OR FILESIZE has changed. However, instead of immediately displaying the change warning that the file has changed when only the filetime has changed but not the filesize, it should then check to see if the hash has changed, and display the change warning only if the hash has also changed. If the hash didn't change, mIRC should just update its saved time/size/filename for that script and move on.

The current method does have a bug because it checks ONLY the filetime and ignores the filesize. This causes mIRC to report a false positive when only the timestamp changes without the contents changing, such as the transition on/off daylight saving time - but also causes mIRC to have a false negative when the contents change without changing the timestamp.

TO REPLICATE THIS BUG:

0. Make sure that "Monitor File Changes" is enabled in the Remotes Script Editor.
1. Take any of your loaded scripts, and make note of the timestamp. For this example, I'll assume the filename is script1.mrc
2. Create a DUMMY folder and copy versions.txt into it.
3. Using a utility which lets you alter the timestamp of a file to a specific time, change the timestamp of the copy of versions.txt to match the timestamp of your script1.mrc, including making sure the the seconds match.
4. Copy the clone of versions.txt on top of the test script script1.mrc and you'll see that mIRC does not give a warning even though the filesize has suddenly changed to 600kb. It doesn't matter whether you use a file manager to do the copying or use "copy -o DUMMY\versions.txt script1.mrc" to replace the contents, there will be no warning if the timestamps match exactly. If at that time you use Alt-R to load script1.mrc into your editor, you'll see the old contents displayed and not versions.txt, because mIRC hasn't determined that a change has occurred.

mIRC's check for the filename is case-insensitive, so using "cmd /k ren script1.mrc SCRIPT1.MRC" will change the case of the script file without generating a warning. I don't see this as a problem - as long as a verification of the hash is made at that time. Even utilities which warn about file changes will allow you to have the option to ignore timestamp differences which are exactly 1:00:00 hour different likely caused by a timezone change, or the timestamp's odd number of seconds altered by being saved into a .zip which keeps only the DOS timestamp that always saves the timestamp with the seconds being even.

In Summary, current behavior is:

Code:
if (%saved_timestamp-made-at-alt_r-saving != $file(filename).mtime) Do_Warning


To avoid unnecessary hashes at frequent intervals while still having better warnings of file-content changes, behavior should change to:

Code:
if (%saved_filesize != $file(filename).size) goto Display_Warning
if (%saved_filename !=== $nopath($file(filename).longfn)) goto hash_check
if (%saved_timestamp != $file(filename).mtime) goto hash_check
return ; (do nothing)
:hash check
if (%saved_hash != $sha256(filename),2) goto Do_Warning
set %saved_filename $nopath($file(filename).longfn)
set %saved_timestamp $file(filename).mtime
return ; don't display warning


If mIRC also wanted to have an additional check of script hashes regardless of identical timestamp or filesize, that could also be an added layer of verification that's done at some regular interval such as hourly. Doing it at the time the Remotes Script Editor opens is probably not a good idea, as it would impose a delay while all N scripts are hashed.

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Using file size also leads to false positive.
If you are going to use the hash, then there's no need to store the modified time or the file size as the hash is meant to be a way to uniquely represent the content of the file, if the hash change, so is the content of the file.
Given what was mentioned by Khaled on this, what you are talking about is certainly not a bug.
Quote:
but also causes mIRC to have a false negative when the contents change without changing the timestamp.
That's not supposed to happen.
The only real improvement would be to use hashes all the time imo.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard