Пример #1
0
        private void handleMissingSyncFolder(Config.SyncConfig.Folder f)
        {
            bool handled = false;

            while (handled == false)
            {
                MissingFolderDialog dialog = new MissingFolderDialog(f);
                dialog.ShowDialog();
                if (dialog.action == MissingFolderDialog.Action.MOVE)
                {
                    String startPath = Directory.GetParent(f.LocalPath).FullName;
                    FolderBrowserDialog fbd = new FolderBrowserDialog();
                    fbd.SelectedPath = startPath;
                    fbd.Description = "Select the folder you have moved or renamed";
                    fbd.ShowNewFolderButton = false;
                    DialogResult result = fbd.ShowDialog();

                    if (result == DialogResult.OK && fbd.SelectedPath.Length > 0)
                    {
                        if (!Directory.Exists(fbd.SelectedPath))
                        {
                            throw new InvalidDataException();
                        }
                        Logger.Info("ControllerBase | Folder '" + f.DisplayName + "' ('" + f.LocalPath + "') moved to '" + fbd.SelectedPath + "'");
                        f.LocalPath = fbd.SelectedPath;

                        AddRepository(f.GetRepoInfo());
                        handled = true;
                    }
                }
                else if (dialog.action == MissingFolderDialog.Action.REMOVE)
                {
                    RemoveRepository(f);
                    ConfigManager.CurrentConfig.Folders.Remove(f);

                    Logger.Info("ControllerBase | Removed folder '" + f.DisplayName + "' from config");
                    handled = true;
                }
                else if (dialog.action == MissingFolderDialog.Action.RECREATE)
                {
                    RepoInfo info = f.GetRepoInfo();
                    RemoveRepository(f);
                    ConfigManager.CurrentConfig.Folders.Remove(f);
                    CreateRepository(info.Name,
                        info.Address,
                        info.User,
                        info.Password.ToString(),
                        info.RepoID,
                        info.RemotePath,
                        info.TargetDirectory,
                        info.getIgnoredPaths().OfType<String>().ToList(),
                        info.SyncAtStartup);
                    Logger.Info("ControllerBase | Folder '" + f.DisplayName + "' recreated");
                    handled = true;
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            //handled == true
            //now resume the sincronization (if ever was suspended)
            //FIXME: the problem is that if the user suspended this repo it will get resumed anyway (ignoring the user setting)
            Program.Controller.ResumeRepositorySynchronization(f.DisplayName);
        }