Пример #1
0
        //Commit is a function to zip an indexing file and related object file
        public static void ExportCommit(Project project, string targetPath, IndexingTree targetIndexing)
        {
            var path = Path.Combine(project.TemporaryFolderPath, targetIndexing.ID);

            //Step 1: Copy all of them to a temp directory
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            else
            {
                Directory.Delete(path, true);
                Directory.CreateDirectory(path);
            }
            //Indexing
            FileInfo indexingFile = new FileInfo(targetIndexing.IndexFilePath);

            indexingFile.CopyTo(Path.Combine(project.TemporaryFolderPath, targetIndexing.ID, indexingFile.Name));

            //Objects
            foreach (IndexingNode n in targetIndexing.GetAllNodes())
            {
                FileInfo objectFile = new FileInfo(ObjectHelper.FindObjectPath(project, n.NameSHA256, n.ContentSHA256));
                objectFile.CopyTo(Path.Combine(project.TemporaryFolderPath, targetIndexing.ID, objectFile.Name));
            }

            //Step 2: Zip them
            ZipFile.CreateFromDirectory(path, targetPath);

            //Step 3: Delete temp file
            Directory.Delete(path, true);
        }
Пример #2
0
        static void Main(string[] _)
        {
            Project      project = new Project("C:\\Users\\14261\\Desktop\\TestFiles");
            IndexingTree it1     = new IndexingTree(project, "85A528AC24E8", "000000000000");

            it1.ImportTreeFromDirectory();
            Console.WriteLine(it1.GetAllNodes().Count);
            it1.ExportTreeToIndexing();
            Console.WriteLine(it1.GetAllNodes().Count);
            it1.ImportTreeFromIndexing();
            Console.WriteLine(it1.GetAllNodes().Count);
        }