/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Utils/Storage/StorageBaseItems/IPasswordProtectedItem.cs
51 строка
2 KB
oxygen dioxide
Feature: Add ZIP encoding selection support for browsing archives with non-UTF-8 filenames (#18529)
05 авг 2026, 18:17
Не верифицирован
05 авг 2026, 18:17
8d5546e
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using FluentFTP.Exceptions; using SevenZip; namespace Files.App.Utils.Storage { public interface IPasswordProtectedItem { StorageCredential Credentials { get; set; } Func<IPasswordProtectedItem, Task<StorageCredential>> PasswordRequestedCallback { get; set; } async Task<TOut> RetryWithCredentialsAsync<TOut>(Func<Task<TOut>> func, Exception exception) { var handled = exception is SevenZipOpenFailedException szofex && szofex.Result is OperationResult.WrongPassword || exception is ExtractionFailedException efex && efex.Result is OperationResult.WrongPassword || exception is FtpAuthenticationException || exception is ICSharpCode.SharpZipLib.Zip.ZipException szlzex && szlzex.Message.Contains("password"); if (!handled || PasswordRequestedCallback is null) throw exception; Credentials = await PasswordRequestedCallback(this); return await func(); } async Task RetryWithCredentialsAsync(Func<Task> func, Exception exception) { var handled = exception is SevenZipOpenFailedException szofex && szofex.Result is OperationResult.WrongPassword || exception is ExtractionFailedException efex && efex.Result is OperationResult.WrongPassword || exception is FtpAuthenticationException || exception is ICSharpCode.SharpZipLib.Zip.ZipException szlzex && szlzex.Message.Contains("password"); if (!handled || PasswordRequestedCallback is null) throw exception; Credentials = await PasswordRequestedCallback(this); await func(); } void CopyFrom(IPasswordProtectedItem parent) { Credentials = parent.Credentials; PasswordRequestedCallback = parent.PasswordRequestedCallback; } } }