Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 internal MegaSource(IMegaApiClient client, Uri uri, INodeInfo node, IArchiveHandler handler)
 {
     this.client  = client;
     this.uri     = uri;
     this.node    = node;
     this.handler = handler;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 8
0
 protected abstract void ConnectClient(IMegaApiClient client);
Ejemplo n.º 9
0
        public static async Task <long> GetFolderSizeAsync(this INodeInfo node, IMegaApiClient client)
        {
            var allNodes = await client.GetNodesAsync();

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

            return(node.GetFolderSize(allNodes));
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 12
0
 protected override void ConnectClient(IMegaApiClient client)
 {
     client.LoginAnonymous();
 }
Ejemplo n.º 13
0
 private static INode GetRootFolderMega(IMegaApiClient client)
 {
     return(client.GetNodes().Single(n => n.Type == NodeType.Root));
 }
Ejemplo n.º 14
0
 private static void LoginMega(IMegaApiClient client, Account account)
 {
     client.Login(account.UserName, account.Password);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 20
0
 public MegaApiClientAsyncWrapper(IMegaApiClient client)
 {
     this.client = client;
     this.client.ApiRequestFailed += this.OnApiRequestFailed;
 }
Ejemplo n.º 21
0
 public CommandExecutor(IMegaApiClient megaApiClient, ILogger logger)
 {
     _megaApiClient = megaApiClient;
     _logger        = logger;
 }