Esempio n. 1
0
        public void Execute()
        {
            var filesInRemote = _remote.ListFiles();
            var filesInCache  = _cacheManager.ListFiles();

            var filesToUpload = filesInCache.Except(filesInRemote).Select(x => x.Name).ToArray();

            if (filesToUpload.Length == 0)
            {
                GitBinConsole.Write("All chunks already present on remote");
            }
            else
            {
                if (filesToUpload.Length == 1)
                {
                    GitBinConsole.Write("Uploading 1 chunk: ");
                }
                else
                {
                    GitBinConsole.Write("Uploading {0} chunks: ", filesToUpload.Length);
                }

                AsyncFileProcessor.ProcessFiles(filesToUpload,
                                                (files, index) =>
                {
                    var file = filesToUpload[index];
                    _remote.UploadFile(_cacheManager.GetPathForFile(file), file);
                });
            }
            Console.WriteLine();
        }
Esempio n. 2
0
        private void DownloadMissingFiles(IEnumerable <string> chunkHashes)
        {
            var filesToDownload = _cacheManager.GetFilenamesNotInCache(chunkHashes);

            if (filesToDownload.Length == 0)
            {
                GitBinConsole.WriteNoPrefix(" All chunks already present in cache");
            }
            else
            {
                if (filesToDownload.Length == 1)
                {
                    GitBinConsole.WriteNoPrefix(" Downloading 1 chunk: ");
                }
                else
                {
                    GitBinConsole.WriteNoPrefix(" Downloading {0} chunks: ", filesToDownload.Length);
                }

                AsyncFileProcessor.ProcessFiles(filesToDownload, DownloadFile);
            }

            GitBinConsole.WriteLine();
        }