Example #1
0
        public void Execute()
        {
            GitBinConsole.WriteLine("Cleaning {0}", _filename);

            var document = new GitBinDocument(_filename);

            var chunkBuffer = new byte[_configurationProvider.ChunkSize];
            int numberOfBytesRead;

            var stdin = Console.OpenStandardInput();

            do
            {
                numberOfBytesRead = stdin.Read(chunkBuffer, 0, chunkBuffer.Length);

                if (numberOfBytesRead > 0)
                {
                    var hash = GetHashForChunk(chunkBuffer, numberOfBytesRead);
                    _cacheManager.WriteFileToCache(hash, chunkBuffer, numberOfBytesRead);
                    document.RecordChunk(hash);
                }
            } while (numberOfBytesRead == chunkBuffer.Length);

            Console.Write(GitBinDocument.ToYaml(document));
            Console.Out.Flush();
        }
Example #2
0
        public void Execute()
        {
            GitBinConsole.WriteLine("Cleaning {0}", _filename);

            var document = new GitBinDocument(_filename);

            var chunkBuffer = new byte[_configurationProvider.ChunkSize];
            int numberOfBytesRead;
            int totalBytesInChunk = 0;

            var stdin = Console.OpenStandardInput();

            do
            {
                numberOfBytesRead = stdin.Read(chunkBuffer, totalBytesInChunk, chunkBuffer.Length - totalBytesInChunk);

                totalBytesInChunk += numberOfBytesRead;

                if ((totalBytesInChunk == chunkBuffer.Length || numberOfBytesRead == 0) && totalBytesInChunk > 0)
                {
                    var hash = GetHashForChunk(chunkBuffer, totalBytesInChunk);
                    _cacheManager.WriteFileToCache(hash, chunkBuffer, totalBytesInChunk);
                    document.RecordChunk(hash);
                    totalBytesInChunk = 0;
                }
            } while (numberOfBytesRead > 0);

            var yamlString = GitBinDocument.ToYaml(document);

            Console.Write(yamlString);
            Console.Out.Flush();
        }
Example #3
0
        public void Execute()
        {
            GitBinConsole.WriteLine("Cleaning {0}", _filename);

            var document = new GitBinDocument(_filename);

            var chunkBuffer = new byte[_configurationProvider.ChunkSize];
            int numberOfBytesRead;

            var stdin = Console.OpenStandardInput();

            do
            {
                numberOfBytesRead = stdin.Read(chunkBuffer, 0, chunkBuffer.Length);

                if (numberOfBytesRead > 0)
                {
                    var hash = GetHashForChunk(chunkBuffer, numberOfBytesRead);
                    _cacheManager.WriteFileToCache(hash, chunkBuffer, numberOfBytesRead);
                    document.RecordChunk(hash);
                }
            } while (numberOfBytesRead == chunkBuffer.Length);

            Console.Write(GitBinDocument.ToYaml(document));
            Console.Out.Flush();
        }
Example #4
0
        public void Execute()
        {
            GitBinConsole.WriteLine("Cleaning {0}", _filename);

            var document = new GitBinDocument(_filename);

            var chunkBuffer = new byte[_configurationProvider.ChunkSize];
            int numberOfBytesRead;
            int totalBytesInChunk = 0;

            var stdin = Console.OpenStandardInput();

            do
            {
                numberOfBytesRead = stdin.Read(chunkBuffer, totalBytesInChunk, chunkBuffer.Length - totalBytesInChunk);

                totalBytesInChunk += numberOfBytesRead;

                if ((totalBytesInChunk == chunkBuffer.Length || numberOfBytesRead == 0) && totalBytesInChunk > 0)
                {
                    var hash = GetHashForChunk(chunkBuffer, totalBytesInChunk);
                    _cacheManager.WriteFileToCache(hash, chunkBuffer, totalBytesInChunk);
                    document.RecordChunk(hash);
                    totalBytesInChunk = 0;
                }
            } while (numberOfBytesRead > 0);

            var yamlString = GitBinDocument.ToYaml(document);

            Console.Write(yamlString);
            Console.Out.Flush();
        }
Example #5
0
        public void FromYaml_DeserializedCorrectly()
        {
            var target = GitBinDocument.FromYaml(new StringReader(expectedYaml));

            Assert.AreEqual("name", target.Filename);
            Assert.AreEqual(2, target.ChunkHashes.Count);
            Assert.AreEqual("abcde", target.ChunkHashes[0]);
            Assert.AreEqual("zyxwv", target.ChunkHashes[1]);
        }
Example #6
0
        public void ToYaml_ProducesValidYaml()
        {
            var doc = new GitBinDocument("name");

            doc.RecordChunk("abcde");
            doc.RecordChunk("zyxwv");

            var actualYaml = GitBinDocument.ToYaml(doc);

            Assert.AreEqual(expectedYaml, actualYaml);
        }
Example #7
0
        public void Execute()
        {
            var stdin    = Console.OpenStandardInput();
            var document = GitBinDocument.FromYaml(new StreamReader(stdin));

            GitBinConsole.Write("Smudging {0}:", document.Filename);

            DownloadMissingFiles(document.ChunkHashes);

            OutputReassembledChunks(document.ChunkHashes);
        }
Example #8
0
        public void Execute()
        {
            var stdin    = Console.OpenStandardInput();
            var document = GitBinDocument.FromYaml(new StreamReader(stdin));

            GitBinConsole.Write("Smudging {0}...", document.Filename);

            DownloadMissingFiles(document.ChunkHashes);
            OutputReassembledChunks(document.ChunkHashes);

/* TODO: move to SparkleShare
 *          string filepath = Path.Combine (Environment.CurrentDirectory,
 *              document.Filename.Replace("/", Path.DirectorySeparatorChar.ToString()));
 *
 *          FileInfo fileInfo         = new FileInfo(filepath);
 *          fileInfo.CreationTimeUtc  = new DateTime(1970, 1, 1).AddSeconds(document.CreationTime);
 *          fileInfo.LastWriteTimeUtc = new DateTime(1970, 1, 1).AddSeconds(document.LastWriteTime);
 */
        }