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(); }
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(); }
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]); }
public void ToYaml_ProducesValidYaml() { var doc = new GitBinDocument("name"); doc.RecordChunk("abcde"); doc.RecordChunk("zyxwv"); var actualYaml = GitBinDocument.ToYaml(doc); Assert.AreEqual(expectedYaml, actualYaml); }
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); }
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); */ }