FubarDevelopment / FtpServer

Portable FTP server written in .NET
http://fubardevelopment.github.io/FtpServer/
MIT License
472 stars 161 forks source link

GenericAccountDirectories always result in a path relative to the rootPath #125

Open JeanRessouche opened 2 years ago

JeanRessouche commented 2 years ago

Hello, i have the following issue, i think that it was mentioned (but denied) in this case .

services.Configure<DotNetFileSystemOptions>(opt => { opt.RootPath = @"c:\anonymous"; }); ... public IAccountDirectories GetDirectories(IAccountInformation accountInformation) { return new GenericAccountDirectories(rootPath: "c:\mypath"); }

Read/Write operations are performed on c:\anonymous\mypath\

Expected: c:\mypath

fubar-coder commented 2 years ago

It seems that there was a similar problem in #74 and it seems that the order of the IAccountDirectoryQuery registration is important. It has the be registered after the AddFtpServer, because it'll be "overwritten" if you register it before the AddFtpServer.

JeanRessouche commented 2 years ago

Hum apparently no i do add the IAccountDirectoryQuery after the AddFtpServer:

               services.Configure<DotNetFileSystemOptions>(opt =>
                {
                    opt.RootPath = _configuration["Messages:Folder"];
                    opt.FlushAfterWrite = true;
                });

                services.AddFtpServer(builder => builder.UseDotNetFileSystem());

                services.AddSingleton<IAccountDirectoryQuery, FtpAccountDirectoryQuery>();

                services.Configure<FtpServerOptions>(opt =>
                {
                    opt.ServerAddress = _configuration["FtpListener:Ip"];
                    opt.Port = _configuration.GetSection("FtpListener").GetValue<int>("Port");
                    opt.MaxActiveConnections = 100;
                    opt.ConnectionInactivityCheckInterval = TimeSpan.FromMinutes(2);
                });

Note: breakpoint do step by my IAccountDirectoryQuery implementation.