The following commit has been merged in the master branch:
commit 49e975d15913007c612925f6021317ee93205e06
Author: Andrei Zavada <[email protected]>
Date:   Sat Dec 15 16:40:55 2012 +0200

    save last_used_version in .expdesign.conf, purge cached profiles before 
tree_scan on upgrade

diff --git a/ChangeLog b/ChangeLog
index c26a846..daa4acd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+v.0.7.6 (2012-12-xx)
+       * Don't forget to save some .expdesign.conf settings.
+       * Purge cached profiles on version upgrade.
+
 v.0.7.5.1 (2012-12-04)
        * Fix Ububtu build.
 v.0.7.5 (2012-12-04)
diff --git a/src/expdesign/loadsave.cc b/src/expdesign/loadsave.cc
index 4fe7dd5..4bc62f8 100644
--- a/src/expdesign/loadsave.cc
+++ b/src/expdesign/loadsave.cc
@@ -46,6 +46,7 @@ load_settings()
                get( config_keys_z, conf);
                get( config_keys_g, conf);
                get( config_keys_b, conf);
+               get( config_keys_s, conf);
 
                for ( size_t t = 0; t < ach::TTunable::_basic_tunables; ++t ) {
                        auto& A = conf.lookup(string("tunable.") + 
ach::tunable_name(t));
@@ -105,6 +106,7 @@ agh::CExpDesign::save_settings()
        confval::put( config_keys_d, conf);
        confval::put( config_keys_g, conf);
        confval::put( config_keys_b, conf);
+       confval::put( config_keys_s, conf);
        confval::put( config_keys_z, conf);
 
       // only save _agh_basic_tunables_
diff --git a/src/expdesign/primaries.cc b/src/expdesign/primaries.cc
index 4c44647..6724484 100644
--- a/src/expdesign/primaries.cc
+++ b/src/expdesign/primaries.cc
@@ -76,6 +76,9 @@ CExpDesign (const string& session_dir_,
                confval::SValidator<bool>("ctl_param.AZAmendment2",     
&ctl_params0.AZAmendment2),
                confval::SValidator<bool>("profile.score_unscored_as_wake",
                                                                        
&score_unscored_as_wake),
+       }),
+       config_keys_s ({
+               confval::SValidator<string>("LastUsedVersion",                  
&last_used_version),
        })
 {
        char *tmp = canonicalize_file_name(session_dir_.c_str());
@@ -106,6 +109,11 @@ CExpDesign (const string& session_dir_,
        omp_set_num_threads( (num_threads == 0) ? agh::global::num_procs : 
num_threads);
        printf( "SMP enabled with %d threads\n", omp_get_max_threads());
 #endif
+       if ( last_used_version != VERSION ) {
+               printf( "Purging old files as we are upgrading from version %s 
to %s\n", last_used_version.c_str(), VERSION);
+       }
+       last_used_version = VERSION;
+
        scan_tree( progress_fun);
 }
 
@@ -573,4 +581,17 @@ sync()
 }
 
 
+
+int
+agh::CExpDesign::
+purge_cached_profiles()
+{
+       DEF_UNIQUE_CHARP (b);
+       ASPRINTF( &b, "find '%s' \\( -name '.*.psd' -or -name '.*.mc' -or -name 
'.*.swu' \\) -delete",
+                 session_dir().c_str());
+       return system( b);
+}
+
+
+
 // eof
diff --git a/src/expdesign/primaries.hh b/src/expdesign/primaries.hh
index 401bcae..94801b3 100644
--- a/src/expdesign/primaries.hh
+++ b/src/expdesign/primaries.hh
@@ -444,6 +444,9 @@ class CExpDesign {
        int load_settings();
        int save_settings();
 
+       string  last_used_version;
+       int purge_cached_profiles();
+
     private:
        enum TStateFlags {
                ok = 0,
@@ -462,6 +465,7 @@ class CExpDesign {
        forward_list<confval::SValidator<int>>          config_keys_d;
        forward_list<confval::SValidator<size_t>>       config_keys_z;
        forward_list<confval::SValidator<bool>>         config_keys_b;
+       forward_list<confval::SValidator<string>>       config_keys_s;
 };
 
 
diff --git a/src/ui/mw/mw-populate.cc b/src/ui/mw/mw-populate.cc
index 08ddab6..544fabe 100644
--- a/src/ui/mw/mw-populate.cc
+++ b/src/ui/mw/mw-populate.cc
@@ -72,10 +72,9 @@ populate( bool do_load)
 
        gtk_window_set_title( wMainWindow,
                              (string ("Aghermann: ") + 
agh::str::homedir2tilda( ED->session_dir())).c_str());
-       if ( last_used_version != VERSION ) {
-               printf( "Upgrading from version %s, here's ChangeLog for 
you\n", last_used_version.c_str());
+       if ( ED->last_used_version != VERSION ) {
+               printf( "Upgrading from version %s, here's ChangeLog for 
you\n", ED->last_used_version.c_str());
                show_changelog();
-               last_used_version = VERSION;
        }
 
        snprintf_buf( "Smooth: %zu", smooth_profile);
diff --git a/src/ui/mw/mw.cc b/src/ui/mw/mw.cc
index 460c2f0..e3079de 100644
--- a/src/ui/mw/mw.cc
+++ b/src/ui/mw/mw.cc
@@ -171,7 +171,6 @@ SExpDesignUI (aghui::SSessionChooser *parent,
                confval::SValidator<string>("Common.CurrentSession",            
&_aghdd_placeholder),
                confval::SValidator<string>("Common.CurrentChannel",            
&_aghtt_placeholder),
                confval::SValidator<string>("Measurements.BrowseCommand",       
&browse_command),
-               confval::SValidator<string>("LastUsedVersion",                  
&last_used_version),
        }),
        config_keys_d ({
                confval::SValidator<int>("Measurements.DisplayProfileMode",     
(int*)&display_profile_type,                    
confval::SValidator<int>::SVFRangeIn ( 0,   1)),
@@ -422,9 +421,7 @@ do_purge_computed()
 {
        aghui::SBusyBlock bb (wMainWindow);
 
-       snprintf_buf( "find '%s' \\( -name '.*.psd' -or -name '.*.mc' -or -name 
'.*.swu' \\) -delete",
-                     ED->session_dir().c_str());
-       if ( system( __buf__) ) {
+       if ( ED->purge_cached_profiles() ) {
                fprintf( stderr, "Command '%s' returned a non-zero status. This 
is suspicious.\n", __buf__);
                gtk_statusbar_pop( sbMainStatusBar, sbMainContextIdGeneral);
                gtk_statusbar_push( sbMainStatusBar, sbMainContextIdGeneral,
diff --git a/src/ui/mw/mw.hh b/src/ui/mw/mw.hh
index c2d51f6..9390cf5 100644
--- a/src/ui/mw/mw.hh
+++ b/src/ui/mw/mw.hh
@@ -150,7 +150,6 @@ class SExpDesignUI
                nodestroy_by_cb:1;
 
       // populate
-       string  last_used_version;
        void show_changelog();
 
        int populate( bool do_load);

-- 
Sleep experiment manager

_______________________________________________
debian-med-commit mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to