Inheritance: IBaseYaml
Esempio n. 1
0
        internal Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection <Uri> hosts, SyncOptions opts)
        {
            var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName);

            if (rsyncFolder.Exists)
            {
                throw new Exception("Already appears to be a repository");
            }

            var packFolder      = GetPackFolder(opts, rsyncFolder);
            var configFile      = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName);
            var wdVersionFile   = rsyncFolder.GetChildFileWithName(Repository.VersionFileName);
            var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName);

            this.Logger().Info("Initializing {0}", folder);
            rsyncFolder.MakeSurePathExists();
            packFolder.MakeSurePathExists();

            var config = new RepoConfig {
                Hosts = hosts.ToList()
            };

            config.PackPath = opts.PackPath?.ToString();

            if (opts.Include != null)
            {
                config.Include = opts.Include;
            }

            if (opts.Exclude != null)
            {
                config.Include = opts.Exclude;
            }

            var guid = opts.RequiredGuid ?? Guid.NewGuid().ToString();

            var packVersion = new RepoVersion {
                Guid = guid
            };

            if (opts.ArchiveFormat != null)
            {
                packVersion.ArchiveFormat = (string)opts.ArchiveFormat;
            }

            var wdVersion = SyncEvilGlobal.Yaml.NewFromYaml <RepoVersion>(packVersion.ToYaml());

            SyncEvilGlobal.Yaml.ToYamlFile(config, configFile);
            SyncEvilGlobal.Yaml.ToYamlFile(packVersion, packVersionFile);
            SyncEvilGlobal.Yaml.ToYamlFile(wdVersion, wdVersionFile);

            return(TryGetRepository(folder, opts, rsyncFolder));
        }
        internal Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection<Uri> hosts, SyncOptions opts) {
            var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName);
            if (rsyncFolder.Exists)
                throw new Exception("Already appears to be a repository");

            var packFolder = GetPackFolder(opts, rsyncFolder);
            var configFile = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName);
            var wdVersionFile = rsyncFolder.GetChildFileWithName(Repository.VersionFileName);
            var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName);

            this.Logger().Info("Initializing {0}", folder);
            rsyncFolder.MakeSurePathExists();
            packFolder.MakeSurePathExists();

            var config = new RepoConfig { Hosts = hosts.ToList() };

            config.PackPath = opts.PackPath?.ToString();

            if (opts.Include != null)
                config.Include = opts.Include;

            if (opts.Exclude != null)
                config.Include = opts.Exclude;

            var guid = opts.RequiredGuid ?? Guid.NewGuid().ToString();

            var packVersion = new RepoVersion { Guid = guid };
            if (opts.ArchiveFormat != null)
                packVersion.ArchiveFormat = (string)opts.ArchiveFormat;

            var wdVersion = SyncEvilGlobal.Yaml.NewFromYaml<RepoVersion>(packVersion.ToYaml());

            SyncEvilGlobal.Yaml.ToYamlFile(config, configFile);
            SyncEvilGlobal.Yaml.ToYamlFile(packVersion, packVersionFile);
            SyncEvilGlobal.Yaml.ToYamlFile(wdVersion, wdVersionFile);

            return TryGetRepository(folder, opts, rsyncFolder);
        }
Esempio n. 3
0
 void TryLoadConfig(bool fallback) {
     try {
         Config = SyncEvilGlobal.Yaml.NewFromYamlFile<RepoConfig>(ConfigFile);
     } catch (FileNotFoundException) {
         Config = new RepoConfig();
     } catch (Exception e) {
         var msg = $"An error has occurred during processing the config file [{RepoName}]";
         this.Logger().FormattedWarnException(e);
         if (!fallback)
             throw new ConfigException(msg);
         Config = new RepoConfig();
     }
 }