public void CreateRepository(string name, Uri address, string user, string password, string repository, string remote_path, string local_path,
List<string> ignoredPaths, bool syncAtStartup)
{
repoInfo = new RepoInfo(name, ConfigManager.CurrentConfig.ConfigPath);
repoInfo.Address = address;
repoInfo.User = user;
repoInfo.Password = new Password(password);
repoInfo.RepoID = repository;
repoInfo.RemotePath = remote_path;
repoInfo.TargetDirectory = local_path;
repoInfo.PollInterval = Config.DEFAULT_POLL_INTERVAL;
repoInfo.IsSuspended = false;
repoInfo.LastSuccessedSync = new DateTime(1900, 01, 01);
repoInfo.SyncAtStartup = syncAtStartup;
repoInfo.MaxUploadRetries = 2;
foreach (string ignore in ignoredPaths)
repoInfo.addIgnorePath(ignore);
// Check that the CmisSync root folder exists.
if (!Directory.Exists(ConfigManager.CurrentConfig.FoldersPath))
{
Logger.Fatal(String.Format("Fetcher | ERROR - Cmis Default Folder {0} does not exist", ConfigManager.CurrentConfig.FoldersPath));
throw new DirectoryNotFoundException("Root folder don't exist !");
}
// Check that the folder is writable.
if (!CmisSync.Lib.Utils.HasWritePermissionOnDir(ConfigManager.CurrentConfig.FoldersPath))
{
Logger.Fatal(String.Format("Fetcher | ERROR - Cmis Default Folder {0} is not writable", ConfigManager.CurrentConfig.FoldersPath));
throw new UnauthorizedAccessException("Root folder is not writable!");
}
// Check that the folder exists.
if (Directory.Exists(repoInfo.TargetDirectory))
{
Logger.Fatal(String.Format("Fetcher | ERROR - Cmis Repository Folder {0} already exist", repoInfo.TargetDirectory));
throw new UnauthorizedAccessException("Repository folder already exists!");
}
// Create the local folder.
Directory.CreateDirectory(repoInfo.TargetDirectory);
// Add folder to XML config file.
ConfigManager.CurrentConfig.AddFolder(repoInfo);
// Initialize in the GUI.
AddRepository(repoInfo);
FolderListChanged();
}