public async Task <bool> Handle(ModDeleteRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <bool> next) { var result = await next(); if (result) { var fileEntry = _index.GetFileByName(request.FileName); _index.RemoveFile(fileEntry.Id); } return(result); }
public async Task <bool> Handle(ModDeleteRequest request, CancellationToken cancellationToken) { var allSources = _fileOpts?.Sources ?? new List <string>(); foreach (var localFi in allSources.Select(sourcePath => new FileInfo(Path.Combine(sourcePath, request.FileName))).Where(localFi => localFi.Exists)) { localFi.Delete(); } return(!allSources.Any(f => new DirectoryInfo(f).GetFiles(Path.GetFileName(request.FileName), SearchOption.TopDirectoryOnly).Any())); }