~kkubasik/beagle/gutsy

« back to all changes in this revision

Viewing changes to beagled/EvolutionMailQueryable/EvolutionSummaryTracker.cs

  • Committer: Kevin Kubasik
  • Date: 2007-10-23 18:09:32 UTC
  • Revision ID: kjk38@kjk38-desktop-20071023180932-vbtm2c7qi4mo7ccu
merge a slew of upstream bugfixes, including a fix for evolution upgrade problems with sqlite

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                {
43
43
                        // Make the on-disk files for folders have sane names
44
44
                        folder_name = folder_name.Replace ('/', '-');
 
45
                        folder_name = folder_name.Replace (':', '_');
45
46
                        folder_name = folder_name.Replace (',', ' '); // Causes problems with the ConnectionString otherwise
46
47
 
47
48
                        string filename = Path.Combine (directory, String.Format ("SummaryTracker-{0}-{1}.db", account_name, folder_name));
48
49
                        bool create_new_db = ! File.Exists (filename);
 
50
                        bool purge_old_db = false;
49
51
 
50
52
                        connection = GetConnection (filename);
51
53
                        try {
52
54
                                connection.Open ();
53
55
                        } catch (ApplicationException) {
54
 
                                create_new_db = true;
 
56
                                purge_old_db = true;
 
57
                        }
 
58
 
 
59
                        if (! create_new_db && ! purge_old_db) {
 
60
                                // Run a dummy SELECT statement to catch more errors
 
61
                                // indicating sqlite version mismatches.
 
62
                                using (SqliteCommand command = new SqliteCommand ()) {
 
63
                                        command.Connection = connection;
 
64
                                        command.CommandText = "SELECT flags FROM mapping WHERE uid = 'fo/ky'";
 
65
 
 
66
                                        SqliteDataReader reader;
 
67
 
 
68
                                        try {
 
69
                                                reader = SqliteUtils.ExecuteReaderOrWait (command);
 
70
                                                reader.Close ();
 
71
                                        } catch (ApplicationException) {
 
72
                                                purge_old_db = true;
 
73
                                        }
 
74
                                }
 
75
                        }
 
76
 
 
77
                        if (purge_old_db) {
55
78
                                connection.Dispose ();
56
79
 
57
80
                                // Purge the old database and create a new one
58
81
                                File.Delete (filename);
59
82
                                connection = GetConnection (filename);
60
83
                                connection.Open ();
 
84
                                create_new_db = true;
61
85
                        }
62
86
 
63
87
                        if (create_new_db)