public void Run() { var ext = System.IO.Path.GetExtension(m_targetpath); var module = m_options.CompressionModule; if (ext == "" || string.Compare(ext, 1, module, 0, module.Length, StringComparison.OrdinalIgnoreCase) != 0) { m_targetpath = m_targetpath + "." + module; } if (System.IO.File.Exists(m_targetpath)) { throw new UserInformationException(string.Format("Output file already exists, not overwriting: {0}", m_targetpath), "BugReportTargetAlreadyExists"); } if (!System.IO.File.Exists(m_options.Dbpath)) { throw new UserInformationException(string.Format("Database file does not exist: {0}", m_options.Dbpath), "BugReportSourceDatabaseNotFound"); } m_result.OperationProgressUpdater.UpdatePhase(OperationPhase.BugReport_Running); m_result.OperationProgressUpdater.UpdateProgress(0); Logging.Log.WriteInformationMessage(LOGTAG, "ScrubbingFilenames", "Scrubbing filenames from database, this may take a while, please wait"); using (var tmp = new Library.Utility.TempFile()) { System.IO.File.Copy(m_options.Dbpath, tmp, true); using (var db = new LocalBugReportDatabase(tmp)) { m_result.SetDatabase(db); db.Fix(); if (m_options.AutoVacuum) { db.Vacuum(); } } using (var stream = new System.IO.FileStream(m_targetpath, FileMode.Create, FileAccess.Write, FileShare.Read)) using (ICompression cm = DynamicLoader.CompressionLoader.GetModule(module, stream, Interface.ArchiveMode.Write, m_options.RawOptions)) { using (var cs = cm.CreateFile("log-database.sqlite", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow)) using (var fs = System.IO.File.Open(tmp, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) Library.Utility.Utility.CopyStream(fs, cs); using (var cs = new System.IO.StreamWriter(cm.CreateFile("system-info.txt", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow))) foreach (var line in SystemInfoHandler.GetSystemInfo()) { cs.WriteLine(line); } } m_result.TargetPath = m_targetpath; } }
public void Run() { var ext = System.IO.Path.GetExtension(m_targetpath); var module = m_options.CompressionModule; if (ext != module) { m_targetpath = m_targetpath + "." + module; } if (System.IO.File.Exists(m_targetpath)) { throw new Exception(string.Format("Output file already exists, not overwriting: {0}", m_targetpath)); } if (!System.IO.File.Exists(m_options.Dbpath)) { throw new Exception(string.Format("Database file does not exist: {0}", m_options.Dbpath)); } m_result.OperationProgressUpdater.UpdatePhase(OperationPhase.BugReport_Running); m_result.OperationProgressUpdater.UpdateProgress(0); m_result.AddMessage("Scrubbing filenames from database, this may take a while, please wait"); using (var tmp = new Library.Utility.TempFile()) { System.IO.File.Copy(m_options.Dbpath, tmp, true); using (var db = new LocalBugReportDatabase(tmp)) { m_result.SetDatabase(db); db.Fix(); } using (var cm = DynamicLoader.CompressionLoader.GetModule(module, m_targetpath, m_options.RawOptions)) { using (var cs = cm.CreateFile("log-database.sqlite", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow)) using (var fs = System.IO.File.Open(tmp, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) Library.Utility.Utility.CopyStream(fs, cs); using (var cs = new System.IO.StreamWriter(cm.CreateFile("system-info.txt", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow))) foreach (var line in SystemInfoHandler.GetSystemInfo()) { cs.WriteLine(line); } } m_result.TargetPath = m_targetpath; } }
public void Run() { var ext = System.IO.Path.GetExtension(m_targetpath); var module = m_options.CompressionModule; if (ext != module) { m_targetpath = m_targetpath + "." + module; } if (System.IO.File.Exists(m_targetpath)) { throw new Exception(string.Format("Output file already exists, not overwriting: {0}", m_targetpath)); } if (!System.IO.File.Exists(m_options.Dbpath)) { throw new Exception(string.Format("Database file does not exist: {0}", m_options.Dbpath)); } m_result.AddMessage("Scrubbing filenames from database, this may take a while, please wait"); using (var tmp = new Library.Utility.TempFile()) { System.IO.File.Copy(m_options.Dbpath, tmp, true); using (var db = new LocalBugReportDatabase(tmp)) { m_result.SetDatabase(db); db.Fix(); } using (var cm = DynamicLoader.CompressionLoader.GetModule(module, m_targetpath, m_options.RawOptions)) { using (var cs = cm.CreateFile("log-database.sqlite", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow)) using (var fs = System.IO.File.Open(tmp, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) Library.Utility.Utility.CopyStream(fs, cs); using (var cs = new System.IO.StreamWriter(cm.CreateFile("system-info.txt", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow))) { cs.WriteLine("Duplicati: {0} ({1})", System.Reflection.Assembly.GetEntryAssembly().FullName, System.Reflection.Assembly.GetExecutingAssembly().FullName); cs.WriteLine("OS: {0}", Environment.OSVersion); cs.WriteLine("Uname: {0}", Duplicati.Library.Utility.Utility.UnameAll); cs.WriteLine("64bit: {0} ({1})", Environment.Is64BitOperatingSystem, Environment.Is64BitProcess); cs.WriteLine("Machinename: {0}", Environment.MachineName); cs.WriteLine("Processors: {0}", Environment.ProcessorCount); cs.WriteLine(".Net Version: {0}", Environment.Version); cs.WriteLine("Mono: {0} ({1}) ({2})", Duplicati.Library.Utility.Utility.IsMono, Duplicati.Library.Utility.Utility.MonoVersion, Duplicati.Library.Utility.Utility.MonoDisplayVersion); Type sqlite = null; string sqliteversion = ""; try { sqlite = Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType; } catch { } if (sqlite != null) { try { sqliteversion = (string)sqlite.GetProperty("SQLiteVersion").GetValue(null, null); } catch { } cs.WriteLine("SQLite: {0} - {1}", sqliteversion, sqlite.FullName); } } } } }