Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/SIL.LCModel/DomainServices/BackupRestore/BackupFileSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class BackupFileSettings : IBackupSettings
private bool m_linkedFiles;
private bool m_supportingFiles;
private bool m_spellCheckAdditions;
private bool m_sendReceiveData;
#endregion

#region Constructors
Expand Down Expand Up @@ -118,6 +119,7 @@ private BackupFileSettings(BackupProjectSettings settings)
m_projectName = settings.ProjectName;
m_projectPathPersisted = LcmFileHelper.GetPathWithoutRoot(settings.ProjectPath);
m_spellCheckAdditions = settings.IncludeSpellCheckAdditions;
m_sendReceiveData = settings.IncludeSendReceiveData;
m_dbVersion = settings.DbVersion;
m_fwVersion = settings.FwVersion;
m_linkedFilesPathRelative = LinkedFilesRelativePathHelper.GetLinkedFilesRelativePathFromFullPath(settings.ProjectsRootFolder, settings.LinkedFilesPath, settings.ProjectPath, settings.ProjectName);
Expand Down Expand Up @@ -372,6 +374,19 @@ public bool IncludeSupportingFiles
get { PopulateSettingsFromZipFileIfNeeded(); return m_supportingFiles; }
private set { m_supportingFiles = value; }
}

/// ------------------------------------------------------------------------------------
/// <summary>
/// Whether or not Send/Receive repository data (.hg and OtherRepositories) is included
/// in the backup/restore.
/// </summary>
/// ------------------------------------------------------------------------------------
[DataMember(Name = "SendReceiveData")]
public bool IncludeSendReceiveData
{
get { PopulateSettingsFromZipFileIfNeeded(); return m_sendReceiveData; }
private set { m_sendReceiveData = value; }
}
#endregion

#region Private helper methods
Expand Down Expand Up @@ -562,6 +577,7 @@ private void CompleteInitialization(BackupFileSettings settings)
m_linkedFiles = settings.IncludeLinkedFiles;
m_supportingFiles = settings.IncludeSupportingFiles;
m_spellCheckAdditions = settings.IncludeSpellCheckAdditions;
m_sendReceiveData = settings.IncludeSendReceiveData;
m_dbVersion = settings.DbVersion;
m_fwVersion = settings.FwVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public BackupProjectSettings(LcmCache cache, IBackupInfo backupInfo, string dest
IncludeLinkedFiles = backupInfo.IncludeLinkedFiles;
IncludeSupportingFiles = backupInfo.IncludeSupportingFiles;
IncludeSpellCheckAdditions = backupInfo.IncludeSpellCheckAdditions;
IncludeSendReceiveData = backupInfo.IncludeSendReceiveData;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/SIL.LCModel/DomainServices/BackupRestore/BackupSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract class BackupSettings : IBackupSettings
private bool m_includeMediaFiles;
private bool m_includeSupportingFiles;
private bool m_includeSpellCheckAdditions;
private bool m_includeSendReceiveData;

/// <summary>
/// The root folder for projects (typically the default, but if these settings represent
Expand Down Expand Up @@ -141,6 +142,15 @@ public bool IncludeSpellCheckAdditions
get { return m_includeSpellCheckAdditions; }
set { m_includeSpellCheckAdditions = value; }
}

///<summary>
/// Whether or not Send/Receive repository data (.hg and OtherRepositories) is included in the backup/restore.
///</summary>
public bool IncludeSendReceiveData
{
get { return m_includeSendReceiveData; }
set { m_includeSendReceiveData = value; }
}
#endregion

#region Paths
Expand Down
5 changes: 5 additions & 0 deletions src/SIL.LCModel/DomainServices/BackupRestore/IBackupInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public interface IBackupInfo
/// Whether or not spell checking additions are included in the backup/restore.
///</summary>
bool IncludeSpellCheckAdditions { get; }

///<summary>
/// Whether or not Send/Receive repository data (.hg and OtherRepositories) is included in the backup/restore.
///</summary>
bool IncludeSendReceiveData { get; }
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ internal IEnumerable<String> CreateListOfFilesToZip()
if (m_settings.IncludeSupportingFiles)
foreach (string file in GetSupportingFilesFilesList())
yield return file;
if (m_settings.IncludeSendReceiveData)
foreach (string file in GetSendReceiveFiles())
yield return file;
}

private IEnumerable<String> GetProjectFolderFilesToBackup()
Expand Down Expand Up @@ -184,6 +187,14 @@ private IEnumerable<String> GetSupportingFilesFilesList()
return GenerateFileListFolderAndSubfolders(m_settings.ProjectSupportingFilesPath);
}

private IEnumerable<String> GetSendReceiveFiles()
{
var files = new HashSet<String>();
files.UnionWith(AllFilesInADirectory(Path.Combine(m_settings.ProjectPath, ".hg")));
files.UnionWith(AllFilesInADirectory(LcmFileHelper.GetOtherRepositoriesDir(m_settings.ProjectPath)));
return files;
}

private IEnumerable<String> GetSpellingDictionaryFilesList()
{
var dictionaryFiles = new HashSet<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ private void RestoreFrom7_0AndNewerBackup(BackupFileSettings fileSettings)

CopySpellingOverrideFilesFromBackupToLocal();
}

if (m_restoreSettings.IncludeSendReceiveData)
{
UncompressFilesContainedInFolderandSubFolders(
LcmFileHelper.GetZipfileFormattedPath(".hg"),
Path.Combine(m_restoreSettings.ProjectPath, ".hg"));
UncompressFilesContainedInFolderandSubFolders(
LcmFileHelper.GetZipfileFormattedPath(LcmFileHelper.OtherRepositories),
LcmFileHelper.GetOtherRepositoriesDir(m_restoreSettings.ProjectPath));
}
}

/// ------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public RestoreProjectSettings(string projectsRootFolder, string projectName, str
IncludeSupportingFiles = (commandLineOptions.IndexOf('f') >= 0);
IncludeLinkedFiles = (commandLineOptions.IndexOf('l') >= 0);
IncludeSpellCheckAdditions = (commandLineOptions.IndexOf('s') >= 0);
IncludeSendReceiveData = (commandLineOptions.IndexOf('r') >= 0);
}

#region Properties
Expand All @@ -87,6 +88,8 @@ public string CommandLineOptions
bldr.Append('l');
if (IncludeSpellCheckAdditions)
bldr.Append('s');
if (IncludeSendReceiveData)
bldr.Append('r');
return bldr.ToString();
}
}
Expand Down
Loading