Ejemplo n.º 1
0
        public NormalizedPath SnapshotState(string imageName)
        {
            NormalizedPath tempPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            FileHelper.DirectoryCopy(UniversePath, tempPath, true);   //Try to escape all handles.
            PlaceHolderSwapEverything(_m, tempPath, UniversePath, PlaceHolderString);
            ReplaceInDirectoriesPaths(tempPath.AppendPart(_ckliMapping), GitWorldStore.CleanPathDirName(UniversePath), GitWorldStore.CleanPathDirName(PlaceHolderString));
            NormalizedPath output = ImageManager.CacheUniverseFolder.AppendPart(imageName + ".zip");

            File.Delete(output);
            ZipFile.CreateFromDirectory(tempPath, output);
            return(output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a <see cref="TestUniverse"/> in a given folder.
        /// </summary>
        /// <param name="path"> The path where the <see cref="TestUniverse"/> will be. The Directory will be deleted when disposed.</param>
        /// <returns></returns>
        public static TestUniverse Create(IActivityMonitor m, NormalizedPath path)
        {
            m.Info($"Creating TestUniverse from {path}.");
            NormalizedPath ckliPath = path.AppendPart(_ckliMapping);

            if (Directory.Exists(ckliPath))
            {
                ReplaceInDirectoriesPaths(
                    ckliPath: ckliPath,
                    oldString: GitWorldStore.CleanPathDirName(PlaceHolderString),
                    newString: GitWorldStore.CleanPathDirName(path)
                    );
            }
            PlaceHolderSwapEverything(m, path, PlaceHolderString, path);
            var userHost = new UserHost(new FakeApplicationLifetime(), ckliPath);
            var output   = new TestUniverse(m, path, userHost);

            userHost.Initialize(m);
            userHost.WorldStore.DeleteStackDefinition(m, "CK");
            userHost.WorldStore.DeleteStackDefinition(m, "CK-Build");
            return(output);
        }