예제 #1
0
        public void Setup()
        {
            this.WebClient = new TestWebClient(new WebClient(WebTimeout), MaxRetry);
            this.Client    = new MegaApiClient(this.WebClient);
            if (this._options.HasFlag(Options.AsyncWrapper))
            {
                this.Client = new MegaApiClientAsyncWrapper(this.Client);
            }

            if (this._options.HasFlag(Options.LoginAuthenticated))
            {
                this.Client.Login(Username, Password);
            }

            if (this._options.HasFlag(Options.LoginAnonymous))
            {
                this.Client.LoginAnonymous();
            }

            if (this._options.HasFlag(Options.Clean))
            {
                Policy
                .Handle <ApiException>(ex => ex.ApiResultCode == ApiResultCode.BadSessionId && this._options.HasFlag(Options.LoginAuthenticated))
                .Or <NotSupportedException>(ex => this._options.HasFlag(Options.LoginAuthenticated))
                .WaitAndRetry(MaxRetry, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), this.ReconnectOnException)
                .Execute(this.SanitizeStorage);
            }
        }
예제 #2
0
 internal MegaSource(IMegaApiClient client, Uri uri, INodeInfo node, IArchiveHandler handler)
 {
     this.client  = client;
     this.uri     = uri;
     this.node    = node;
     this.handler = handler;
 }
예제 #3
0
        public void Execute(IMegaApiClient megaApiClient,
                            IMegaNzItemCollection megaNzItemCollection,
                            IFileManager fileManager,
                            IProgress <double> progressNotifier)
        {
            var nodeToDelete = megaNzItemCollection.GetByPath(PathToDelete);

            megaApiClient.Delete(nodeToDelete);
            megaNzItemCollection.RemoveItemByExactPath(PathToDelete);
        }
예제 #4
0
        private static IEnumerable <MegaNzItem> GenerateListFromMegaNz(IMegaApiClient megaApiClient)
        {
            logger.Trace("Reading nodes from MegaNZ");
            var remoteNodeList = megaApiClient
                                 .GetNodes()
                                 .ToList();

            var generator = new MegaNzItemListGenerator();

            return(generator.Generate(remoteNodeList));
        }
예제 #5
0
        public void Execute(IMegaApiClient megaApiClient,
                            IMegaNzItemCollection megaNzItemCollection,
                            IFileManager fileManager,
                            IProgress <double> progressNotifier)
        {
            // Find the MegaNZ node related to the parent folder
            var parent = megaNzItemCollection.GetByPath(ParentPath);

            // Create the new folder
            var newNode = megaApiClient.CreateFolder(Name, parent);

            // Update the item collection
            megaNzItemCollection.Add(newNode);
        }
예제 #6
0
 public void Execute(IMegaApiClient megaApiClient,
                     IMegaNzItemCollection megaNzItemCollection,
                     IFileManager fileManager,
                     IProgress <double> progressNotifier)
 {
     using (var filestream = fileManager.GetStreamToReadFile(SourcePath))
     {
         var sourceFileName   = System.IO.Path.GetFileName(SourcePath);
         var remoteFileName   = NameHandler.BuildRemoteFileName(sourceFileName, LastModifiedDate);
         var parentMegaNzNode = megaNzItemCollection.GetByPath(DestinationPath);
         var newMegaNzNode    = megaApiClient.UploadAsync(filestream, remoteFileName, parentMegaNzNode, progressNotifier).Result;
         megaNzItemCollection.Add(newMegaNzNode);
     }
 }
 protected override void ConnectClient(IMegaApiClient client)
 {
     Assert.False(string.IsNullOrEmpty(Password), $"Environment variable {MegaApiClientPasswordEnvironment} not set.");
     client.Login(Inputs.UsernameAccount, Password);
 }
예제 #8
0
 protected abstract void ConnectClient(IMegaApiClient client);
예제 #9
0
        public static async Task <long> GetFolderSizeAsync(this INodeInfo node, IMegaApiClient client)
        {
            var allNodes = await client.GetNodesAsync();

            return(await node.GetFolderSizeAsync(allNodes));
        }
예제 #10
0
        public static long GetFolderSize(this INodeInfo node, IMegaApiClient client)
        {
            var allNodes = client.GetNodes();

            return(node.GetFolderSize(allNodes));
        }
예제 #11
0
 /// <summary>
 /// Constructor method.
 /// </summary>
 /// <param name="window"><see cref="MainWindow"/> where are placed GUI elements to be updated to show progress.</param>
 /// <param name="url">mega.nz link to download a .zip including the .exe to be launched and all the files needed.</param>
 public MegaDownloader(MainWindow window, string url) : base(window, url)
 {
     client = new MegaApiClient();
 }
예제 #12
0
 protected override void ConnectClient(IMegaApiClient client)
 {
     client.LoginAnonymous();
 }
예제 #13
0
 private static INode GetRootFolderMega(IMegaApiClient client)
 {
     return(client.GetNodes().Single(n => n.Type == NodeType.Root));
 }
예제 #14
0
 private static void LoginMega(IMegaApiClient client, Account account)
 {
     client.Login(account.UserName, account.Password);
 }
예제 #15
0
        // Token: 0x060008B7 RID: 2231 RVA: 0x0003BB7C File Offset: 0x00039D7C
        public static long GetFolderSize(this INodeInfo node, IMegaApiClient client)
        {
            IEnumerable <INode> nodes = client.GetNodes();

            return(node.GetFolderSize(nodes));
        }
 public MegaApiClientAsyncWrapper(IMegaApiClient client)
 {
     this.client = client;
 }
예제 #17
0
 protected override void ConnectClient(IMegaApiClient client)
 {
     client.Login(Username, Password);
 }
 public MegaApiClientAsyncWrapper(IMegaApiClient client)
 {
     _client = client;
     _client.ApiRequestFailed += OnApiRequestFailed;
 }
 protected override void ConnectClient(IMegaApiClient client)
 {
 }
예제 #20
0
 public MegaApiClientAsyncWrapper(IMegaApiClient client)
 {
     this.client = client;
     this.client.ApiRequestFailed += this.OnApiRequestFailed;
 }
예제 #21
0
 public CommandExecutor(IMegaApiClient megaApiClient, ILogger logger)
 {
     _megaApiClient = megaApiClient;
     _logger        = logger;
 }