public static void Run(FSpotDatabaseConnection database) { db = database; db_version = GetDatabaseVersion (); if (updates.Count == 0) return; if (db_version == LatestVersion) return; else if (db_version > LatestVersion) { if (!silent) Log.Information ("The existing database version is more recent than this version of F-Spot expects."); return; } uint timer = 0; if (!silent) timer = Log.InformationTimerStart ("Updating F-Spot Database"); // Only create and show the dialog if one or more of the updates to be done is // marked as being slow bool slow = false; foreach (Version version in updates.Keys) { if (version > db_version && (updates [version] as Update).IsSlow) slow = true; break; } if (slow && !silent) { dialog = new ProgressDialog (Catalog.GetString ("Updating F-Spot Database"), ProgressDialog.CancelButtonType.None, 0, null); dialog.Message.Text = Catalog.GetString ("Please wait while your F-Spot gallery's database is updated. This may take some time."); dialog.Bar.Fraction = 0.0; dialog.Modal = false; dialog.SkipTaskbarHint = true; dialog.WindowPosition = WindowPosition.Center; dialog.ShowAll (); dialog.Present (); dialog.QueueDraw (); } db.BeginTransaction (); try { List<Version> keys = new List<Version> (); foreach (Version k in updates.Keys) { keys.Add(k); } keys.Sort (); foreach (Version version in keys) { if (version <= db_version) continue; Pulse (); (updates [version] as Update).Execute (db, db_version); } db.CommitTransaction (); } catch (Exception e) { if (!silent) { Log.DebugException (e); Log.Warning ("Rolling back database changes because of Exception"); } // There was an error, roll back the database db.RollbackTransaction (); // Pass the exception on, this is fatal throw e; } if (dialog != null) dialog.Destroy (); if (db_version == LatestVersion && !silent) Log.InformationTimerPrint (timer, "Database updates completed successfully (in {0})."); }
public static void Run(FSpotDatabaseConnection database) { db = database; db_version = GetDatabaseVersion(); if (updates.Count == 0) { return; } if (db_version == LatestVersion) { return; } else if (db_version > LatestVersion) { if (!silent) { Log.Information("The existing database version is more recent than this version of F-Spot expects."); } return; } uint timer = 0; if (!silent) { timer = Log.InformationTimerStart("Updating F-Spot Database"); } // Only create and show the dialog if one or more of the updates to be done is // marked as being slow bool slow = false; foreach (Version version in updates.Keys) { if (version > db_version && (updates [version] as Update).IsSlow) { slow = true; } break; } if (slow && !silent) { dialog = new ProgressDialog(Catalog.GetString("Updating F-Spot Database"), ProgressDialog.CancelButtonType.None, 0, null); dialog.Message.Text = Catalog.GetString("Please wait while your F-Spot gallery's database is updated. This may take some time."); dialog.Bar.Fraction = 0.0; dialog.Modal = false; dialog.SkipTaskbarHint = true; dialog.WindowPosition = WindowPosition.Center; dialog.ShowAll(); dialog.Present(); dialog.QueueDraw(); } db.BeginTransaction(); try { List <Version> keys = new List <Version> (); foreach (Version k in updates.Keys) { keys.Add(k); } keys.Sort(); foreach (Version version in keys) { if (version <= db_version) { continue; } Pulse(); (updates [version] as Update).Execute(db, db_version); } db.CommitTransaction(); } catch (Exception e) { if (!silent) { Log.DebugException(e); Log.Warning("Rolling back database changes because of Exception"); } // There was an error, roll back the database db.RollbackTransaction(); // Pass the exception on, this is fatal throw e; } if (dialog != null) { dialog.Destroy(); } if (db_version == LatestVersion && !silent) { Log.InformationTimerPrint(timer, "Database updates completed successfully (in {0})."); } }
public static void Run(FSpotDatabaseConnection database, IUpdaterUI updaterDialog) { db = database; dialog = updaterDialog; db_version = GetDatabaseVersion(); if (updates.Count == 0) { return; } if (db_version == LatestVersion) { return; } else if (db_version > LatestVersion) { if (!silent) { Log.Information("The existing database version is more recent than this version of F-Spot expects."); } return; } uint timer = 0; if (!silent) { timer = Log.InformationTimerStart("Updating F-Spot Database"); } // Only create and show the dialog if one or more of the updates to be done is // marked as being slow bool slow = false; foreach (Version version in updates.Keys) { if (version > db_version && (updates [version] as Update).IsSlow) { slow = true; } break; } if (slow && !silent) { dialog.Show(); } db.BeginTransaction(); try { List <Version> keys = new List <Version> (); foreach (Version k in updates.Keys) { keys.Add(k); } keys.Sort(); foreach (Version version in keys) { if (version <= db_version) { continue; } dialog.Pulse(); (updates [version] as Update).Execute(db, db_version); } db.CommitTransaction(); } catch (Exception e) { if (!silent) { Log.DebugException(e); Log.Warning("Rolling back database changes because of Exception"); } // There was an error, roll back the database db.RollbackTransaction(); // Pass the exception on, this is fatal throw e; } dialog.Destroy(); if (db_version == LatestVersion && !silent) { Log.InformationTimerPrint(timer, "Database updates completed successfully (in {0})."); } }