Ejemplo n.º 1
0
        private async Task <IRemoteFolder> GetLastUploadFolder(IRemoteClient client, Server server, Deployment deployment)
        {
            string uploadPath = server.Paths.Deploy;

            if (!await client.FolderExists(uploadPath))
            {
                return(null);
            }

            IRemoteFolder folder = await client.GetFolder(uploadPath);

            if (folder == null)
            {
                return(null);
            }

            foreach (string dateFolderPath in folder.SubFolders.Reverse().Select(x => x.Path))
            {
                IRemoteFolder dateFolder = await GetFolder(client, dateFolderPath);

                IRemoteFolder uploadFolder = dateFolder.SubFolders.Reverse()
                                             .FirstOrDefault(x => x.Name.StartsWith(deployment.Name, StringComparison.OrdinalIgnoreCase));
                if (uploadFolder != null)
                {
                    return(uploadFolder);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private async Task <IRemoteFolder> GetFolder(IRemoteClient client, string path)
        {
            path = path ?? "";
            if (_remoteFolderCache.ContainsKey(path))
            {
                return(_remoteFolderCache[path]);
            }

            try
            {
                IRemoteFolder folder = await client.GetFolder(path);

                _remoteFolderCache.Add(path, folder);
                return(folder);
            }
            catch (FtpCommandException)
            {
                return(null);
            }
        }