/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App.Storage/Ftp/FtpStorageService.cs
40 строк
1 KB
0x5BFA
Code Quality: Re-organize the structure of Files.App.Storage (#17340)
29 июл 2025, 00:54
Не верифицирован
29 июл 2025, 00:54
7203007
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using FluentFTP; using System.IO; namespace Files.App.Storage { /// <inheritdoc cref="IFtpStorageService"/> public sealed class FtpStorageService : IFtpStorageService { /// <inheritdoc/> public async Task<IFolder> GetFolderAsync(string id, CancellationToken cancellationToken = default) { using var ftpClient = FtpHelpers.GetFtpClient(id); await ftpClient.EnsureConnectedAsync(cancellationToken); var ftpPath = FtpHelpers.GetFtpPath(id); var item = await ftpClient.GetObjectInfo(ftpPath, token: cancellationToken); if (item is null || item.Type != FtpObjectType.Directory) throw new DirectoryNotFoundException("Directory was not found from path."); return new FtpStorageFolder(ftpPath, item.Name, null); } /// <inheritdoc/> public async Task<IFile> GetFileAsync(string id, CancellationToken cancellationToken = default) { using var ftpClient = FtpHelpers.GetFtpClient(id); await ftpClient.EnsureConnectedAsync(cancellationToken); var ftpPath = FtpHelpers.GetFtpPath(id); var item = await ftpClient.GetObjectInfo(ftpPath, token: cancellationToken); if (item is null || item.Type != FtpObjectType.File) throw new FileNotFoundException("File was not found from path."); return new FtpStorageFile(ftpPath, item.Name, null); } } }