Feature - Implemented svn update at login -> switch to once per day, global

Bale

Minion
Right now there is a preference svnUpdateOnLogin

The problem is that this will update all scripts at every time the character logs in. It will even do this for every characters despite the fact that they all share the same svn settings. We are very careful about page hits for kolmafia and while that is not sourceforge, it would only be reasonable to be considerate of them as well as the extra time required for svn updates at every login for every character.

I propose that a new global preference is added, _dailySvnUpdate (default: false) which is set to true if an svn update is performed. Unless _dailySvnUpdate is false, svnUpdateOnLogin will do nothing.

Scripts might even want to check _dailySvnUpdate to see if they have been checked for updates today, in case svnUpdateOnLogin is false.


Alternate (more complicated) solution. Global preference lastSvnUpdate contains today_to_string() of last svn update.
 
Last edited:
r12188

Notably, first global preference that starts with _. I named it _svnUpdated since the underscore already implies daily. Now I'll just go put my PIN number into this ATM machine.
 
ROTFLOL! That's awesome~! Good point about the name.

Now I can add the following line to a script:

if(get_property("_svnUpdated") == "false") cli_execute("svn update project-name");

Most awesome method ever for ensuring that data files are updated.
 
Last edited:
Yep. Be aware that scripts are interpreted then run entirely from memory, so if svn update updates the script that calls it, it won't do anything until the next time you run that script. You probably know this already but putting it here for posterity.
 
ROTFLOL! That's awesome~! Good point about the name.

Now I can add the following line to a script:

if(get_property("_svnUpdated") == "false") cli_execute("svn update project-name");

Most awesome method ever for ensuring that data files are updated.

Won't that try to update the script every time it is run? As long as someone isn't updating all their scripts at login, which is when that line would do anything to begin with.
 
Er yeah, I think bale edited some things in.

_svnUpdated is set to true whenever svn update is run, i.e. the update-everything version. It wouldn't really make sense to set it on an individual project update.
 
Er yeah, I think bale edited some things in.

Guilty. I added the project-name part while you were still typing your reply.


Won't that try to update the script every time it is run? As long as someone isn't updating all their scripts at login, which is when that line would do anything to begin with.

I did not realize that. Thank you for pointing it out. The solution is simple enough.

PHP:
if(get_property("_svnUpdated") == "false" && get_property("_projectnameUpdated") != "true") {
   cli_execute("svn update project-name");
   set_property("_projectUpdated", "true");
}


Now I can ensure that data files (and incidentally, script, although only on next execution) are properly updated.
 
Yep. Be aware that scripts are interpreted then run entirely from memory, so if svn update updates the script that calls it, it won't do anything until the next time you run that script. You probably know this already but putting it here for posterity.

In that case, might it be useful to provide functionality for a) identifying whether a script is up-to-date and b) restarting said script, if it isn't?

(directed primarily at fellow scripters, although I'm always interested to hear what Mafia developers think)
 
You can hack around it with creating _preferences for now if that floats your boat.

My boat is floating! Also _prefs are extra awesome lately now that mafia sets them silently and deletes them each day. They're invisible and disposable! Of course I'd probably switch over to the proper API when it comes out.
 
Back
Top