private bool DoBackup() { if (!Base.IsDocumentLoaded) { return(true); } BackupThreadArgs backupThreadArgs = new BackupThreadArgs(); if (Base.Document.CanTextBeSaved) { backupThreadArgs.TextFilePropertiesClone = Base.Document.TextFile.Clone() as SubLib.Core.Domain.FileProperties; } if (Base.Document.CanTranslationBeSaved) { backupThreadArgs.TranslationFilePropertiesClone = Base.Document.TranslationFile.Clone() as SubLib.Core.Domain.FileProperties; } if ((backupThreadArgs.TextFilePropertiesClone != null) || (backupThreadArgs.TranslationFilePropertiesClone != null)) { backupThreadArgs.SubtitlesClone = Base.Document.Subtitles.Clone() as SubLib.Core.Domain.Subtitles; Thread backupThread = new Thread(SaveSubtitleFiles); backupThread.Start(backupThreadArgs); } return(true); }
private bool DoBackup() { if (!Base.IsDocumentLoaded) { return true; } BackupThreadArgs backupThreadArgs = new BackupThreadArgs(); if (Base.Document.CanTextBeSaved) { backupThreadArgs.TextFilePropertiesClone = Base.Document.TextFile.Clone() as SubLib.Core.Domain.FileProperties; } if (Base.Document.CanTranslationBeSaved) { backupThreadArgs.TranslationFilePropertiesClone = Base.Document.TranslationFile.Clone() as SubLib.Core.Domain.FileProperties; } if ((backupThreadArgs.TextFilePropertiesClone != null) || (backupThreadArgs.TranslationFilePropertiesClone != null)) { backupThreadArgs.SubtitlesClone = Base.Document.Subtitles.Clone() as SubLib.Core.Domain.Subtitles; Thread backupThread = new Thread(SaveSubtitleFiles); backupThread.Start(backupThreadArgs); } return true; }
private void SaveSubtitleFiles(object backupThreadArgs) { try { BackupThreadArgs args = backupThreadArgs as BackupThreadArgs; /* Save subtitle file */ if ((args.TextFilePropertiesClone != null) && (args.TextFilePropertiesClone.SubtitleType != SubtitleType.Unknown) && (args.TextFilePropertiesClone.IsPathRooted)) { args.TextFilePropertiesClone.Path += "~"; SaveFile(args.SubtitlesClone, args.TextFilePropertiesClone, SubtitleTextType.Text); } /* Save translation file */ if ((args.TranslationFilePropertiesClone != null) && (args.TranslationFilePropertiesClone.SubtitleType != SubtitleType.Unknown) && (args.TranslationFilePropertiesClone.IsPathRooted)) { args.TranslationFilePropertiesClone.Path += "~"; SaveFile(args.SubtitlesClone, args.TranslationFilePropertiesClone, SubtitleTextType.Translation); } } catch (Exception e) { Logger.Error(e, "Caught an exception while creating backup files"); } }