コード例 #1
0
        public virtual void Run()
        {
            if (!System.IO.File.Exists(m_options.Dbpath))
            {
                throw new Exception(string.Format("Database file does not exist: {0}", m_options.Dbpath));
            }

            using (var db = new LocalDeleteDatabase(m_options.Dbpath, "Compact"))
            {
                var tr = db.BeginTransaction();
                try
                {
                    m_result.SetDatabase(db);
                    Utility.UpdateOptionsFromDb(db, m_options);
                    Utility.VerifyParameters(db, m_options);

                    var changed = DoCompact(db, false, ref tr, null);

                    if (changed && m_options.UploadVerificationFile)
                    {
                        FilelistProcessor.UploadVerificationFile(m_backendurl, m_options, m_result.BackendWriter, db, null);
                    }

                    if (!m_options.Dryrun)
                    {
                        using (new Logging.Timer(LOGTAG, "CommitCompact", "CommitCompact"))
                            tr.Commit();
                        if (changed)
                        {
                            db.WriteResults();
                            if (m_options.AutoVacuum)
                            {
                                db.Vacuum();
                            }
                        }
                    }
                    else
                    {
                        tr.Rollback();
                    }

                    tr = null;
                }
                finally
                {
                    if (tr != null)
                    {
                        try { tr.Rollback(); }
                        catch { }
                    }
                }
            }
        }
コード例 #2
0
        public virtual void Run()
        {
            if (!System.IO.File.Exists(m_options.Dbpath))
            {
                throw new Exception(string.Format("Database file does not exist: {0}", m_options.Dbpath));
            }

            using (var db = new LocalDeleteDatabase(m_options.Dbpath, true))
                using (var tr = db.BeginTransaction())
                {
                    m_result.SetDatabase(db);
                    Utility.VerifyParameters(db, m_options);

                    var changed = DoCompact(db, false, tr);

                    if (changed && m_options.UploadVerificationFile)
                    {
                        FilelistProcessor.UploadVerificationFile(m_backendurl, m_options, m_result.BackendWriter, db, tr);
                    }

                    if (!m_options.Dryrun)
                    {
                        using (new Logging.Timer("CommitCompact"))
                            tr.Commit();
                        if (changed)
                        {
                            db.WriteResults();
                            db.Vacuum();
                        }
                    }
                    else
                    {
                        tr.Rollback();
                    }
                }
        }