Example #1
0
        public static void Main(string[] args)
        {
            Properties props = new Properties();

            try
            {
                Parser p;
                p = ParserFactory.BuildParser(props);
                p.OptStyle = OptStyle.Unix;
                p.UnixShortOption = UnixShortOption.CollapseShort;
                p.UnknownOptHandleType = UnknownOptHandleType.Warning;
                p.DupOptHandleType = DupOptHandleType.Warning;
                p.CaseSensitive = true;
                p.OptionWarning += new WarningEventHandler(OnOptionWarning);
                p.SearchEnvironment = true;
                p.Parse(args);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception!");
                return;
            }

            try
            {
                switch (props.operation)
                {
                    case "interactive":
                        {
                            ProcessInteractiveCommands(props);
                            break;
                        }
                    case "upload":
                        {
                            ProcessUpload(props);
                            break;
                        }
                    case "download":
                        {
                            ProcessDownload(props);
                            break;
                        }
                    case "list":
                        {
                            ProcessList(props);
                            break;
                        }
                    default:
                        return;
                }
            }
            catch (Exception e)
            {
                System.IO.File.WriteAllText("./GlacierizerStackTrace.log", e.StackTrace);
                throw e;
            }
        }
Example #2
0
        private static void ProcessDownload(Properties props)
        {
            GlacierizerDownloader downloader = new GlacierizerDownloader(props);

            if (downloader.Download())
            {
                Console.WriteLine("Downloaded: " + Utilities.BytesToHuman(downloader.TotalBytesDownloaded));
                Console.WriteLine("Success!");
            }
        }
Example #3
0
        public GlacierizerVaults(Properties props)
        {
            vaultName = props.vault;
            if (props.jobId.Length != 0)
                jobId = props.jobId;

            glacierAPI = new PWGlacierAPI(vaultName, "");

            if (props.filename.Length != 0)
                outputStream = File.Open(props.filename, FileMode.OpenOrCreate);
            else
                outputStream = Console.OpenStandardOutput();
        }
        public GlacierizerDownloader(Properties props)
        {
            glacierAPI = new PWGlacierAPI(props.vault, props.archive);

            if (props.jobId.Length != 0)
                jobId = props.jobId;

            archiveId = props.archive;
            partSize = props.size;
            maxNumThreads = props.threads;

            if (props.filename == null)
                outputStream = Console.OpenStandardOutput();
            else
                outputStream = File.Open(props.filename, FileMode.OpenOrCreate);
        }
Example #5
0
        private static void ProcessInteractiveCommands(Properties props)
        {
            Console.Write("What would you like to do (upload, download, list, resume)? ");
            string operation = Console.ReadLine();

            Console.Write("Please enter Vault name: ");
            props.vault = Console.ReadLine();

            switch (operation)
            {
                case "upload":
                case "download":
                    {
                        Console.Write("Enter an existing retrieval job ID (leave empty if new request): ");
                        props.jobId = Console.ReadLine();

                        Console.Write("Enter the archive ID: ");
                        props.archive = Console.ReadLine();

                        GlacierizerDownloader downloader = new GlacierizerDownloader(props);

                        if (downloader.Download())
                        {
                            Console.WriteLine("Downloaded: " + Utilities.BytesToHuman(downloader.TotalBytesDownloaded));
                            Console.WriteLine("Success!");
                        }

                        break;
                    }
                case "resume":
                    {

                        break;
                    }
                case "list":
                default:
                    break;
            }
        }
Example #6
0
        private static void ProcessUpload(Properties props)
        {
            Stream input;
            if (props.filename.Length > 0)
            {
                input = File.Open(props.filename, FileMode.Open);
            }
            else
                input = Console.OpenStandardInput();

            GlacierAPIInterface api = new PWGlacierAPI(props.vault, props.archive);
            GlacierizerUploader uploader = new GlacierizerUploader(api, input, props.size, props.threads);

            if (uploader.Upload())
            {
                Console.WriteLine("Uploaded: " + Utilities.BytesToHuman(uploader.TotalBytesUploaded));
                Console.WriteLine("Success!");
                Console.WriteLine("ArchiveId: " + uploader.ArchiveId);

                string archiveIdPath = "./" + props.vault + "_" + props.archive + "_uploaded.archive.id";
                System.IO.File.WriteAllText(archiveIdPath, uploader.ArchiveId);

                string hashPath = "./" + props.vault + "_" + props.archive + "_uploaded.hashlist";
                System.IO.File.WriteAllText(hashPath, uploader.GetHashList());
            }
        }
Example #7
0
 private static void ProcessList(Properties props)
 {
     GlacierizerVaults vaults = new GlacierizerVaults(props);
     if (vaults.GetVaultInventory())
     {
     }
 }