Inheritance: IBaseYaml
        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));
        }
 public void UpdateSynqState(ISupportModding game, PackageItem package) {
     Contract.Requires<ArgumentNullException>(package != null);
     _package = package;
     SetSharedState(game);
     _isValidSixSync = false;
     _isValidSixSyncPack = false;
     _sixSyncRepoExists = false;
     _sixSyncVersionInfo = null;
     _package.UpdateCurrentVersion();
     Revision = GetSynqRevision();
     DesiredRevision = GetSynqDesiredRevision();
     LatestRevision = GetSynqLatestRevision();
     State = !ModMatchesActiveGame(game) ? ContentState.Incompatible : GetSynqModState();
     //Cheat.PublishDomainEvent(new ModInfoChangedEvent(new ModInfo(_mod)));
 }
 public void UpdateSixSyncState(ISupportModding game) {
     SetSharedState(game);
     SetSixSyncPaths();
     _sixSyncRepoExists = DoesRepoExist();
     _isValidSixSync = IsValidSixSync();
     _isValidSixSyncPack = IsPackValidSixSync();
     _sixSyncVersionInfo = _isValidSixSync ? TryReadRepoFile(_repoYamlFile) : null;
     try {
         DesiredRevision = _mod.Version;
         LatestRevision = _mod.Version;
         Guid = GetSixSyncGuid();
         Revision = GetSixSyncRevision(false);
         State = !ModMatchesActiveGame(game) ? ContentState.Incompatible : GetSixSyncModState();
     } finally {
         _sixSyncVersionInfo = null;
     }
 }
        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);
        }
        void ConvertFormat(string format) {
            Contract.Requires<ArchiveFormatUnsupported>(ArchiveFormats.Any(x => x == format));
            if (format == ArchiveFormat)
                throw new ArgumentOutOfRangeException("Repository already of same format");

            var previous = ArchiveFormat;

            this.Logger().Info("Converting from {0} to {1}", previous, format);
            if (!WdVersion.WD.Any() && !WdVersion.Pack.Any()) {
                ArchiveFormat = format;
                return;
            }
            WdVersion = new RepoVersion();
            PackVersion = new RepoVersion();

            ArchiveFormat = format;
            SaveVersions();
            CleanupZsyncFiles();

            foreach (
                var f in Directory.EnumerateFiles(PackFolder.ToString(), "*" + previous, SearchOption.AllDirectories))
                Tools.FileUtil.Ops.DeleteWithRetry(f);

            Commit(false, false);
        }
 void TryLoadWDVersion() {
     try {
         WdVersion = SyncEvilGlobal.Yaml.NewFromYamlFile<RepoVersion>(WdVersionFile);
     } catch (Exception e) {
         this.Logger().FormattedWarnException(e);
         WdVersion = new RepoVersion();
     }
 }