Пример #1
0
        public Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection<Uri> hosts,
            Dictionary<string, object> opts = null) {
            Contract.Requires<ArgumentNullException>(folder != null);
            Contract.Requires<ArgumentNullException>(hosts != null);

            if (opts == null)
                opts = new Dictionary<string, object>();

            var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName);
            if (rsyncFolder.Exists)
                throw new Exception("Already appears to be a repository");

            var packFolder = Path.Combine(opts.ContainsKey("pack_path")
                ? ((string) opts["pack_path"])
                : rsyncFolder.ToString(),
                Repository.PackFolderName).ToAbsoluteDirectoryPath();

            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.ToArray()};

            if (opts.ContainsKey("pack_path"))
                config.PackPath = (string) opts["pack_path"];

            if (opts.ContainsKey("include"))
                config.Include = (string[]) opts["include"];

            if (opts.ContainsKey("exclude"))
                config.Exclude = (string[]) opts["exclude"];

            var guid = opts.ContainsKey("required_guid")
                ? (string) opts["required_guid"]
                : Guid.NewGuid().ToString();

            var packVersion = new RepoVersion {Guid = guid};
            if (opts.ContainsKey("archive_format"))
                packVersion.ArchiveFormat = (string) opts["archive_format"];

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

            config.SaveYaml(configFile);
            packVersion.SaveYaml(packVersionFile);
            wdVersion.SaveYaml(wdVersionFile);

            return TryGetRepository(folder.ToString(), opts, rsyncFolder.ToString());
        }
Пример #2
0
 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();
     //Common.App.Mediator.Notify(new ModInfoChangedEvent(new ModInfo(_mod)));
 }
Пример #3
0
 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;
     }
 }
Пример #4
0
        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);
        }
Пример #5
0
 void TryLoadWDVersion() {
     try {
         WdVersion = YamlExtensions.NewFromYamlFile<RepoVersion>(WdVersionFile);
     } catch (Exception e) {
         this.Logger().FormattedWarnException(e);
         WdVersion = new RepoVersion();
     }
 }