yavsccli target

This commit is contained in:
Paul Schneider 2021-03-10 01:41:31 +00:00
commit f39d6c48c5
15 changed files with 85 additions and 107 deletions

View file

@ -143,11 +143,13 @@ namespace Yavsc.Helpers
using (Process p = new Process())
{
p.StartInfo.WorkingDirectory = tempdir;
p.StartInfo = new ProcessStartInfo();
p.StartInfo.UseShellExecute = false;
p.StartInfo.WorkingDirectory = tempdir;
p.StartInfo.FileName = "/usr/bin/texi2pdf";
p.StartInfo.Arguments = $"--batch --build-dir=. -o {fo.FullName} {fi.FullName}";
p.StartInfo = new ProcessStartInfo
{
UseShellExecute = false,
WorkingDirectory = tempdir,
FileName = "/usr/bin/texi2pdf",
Arguments = $"--batch --build-dir=. -o {fo.FullName} {fi.FullName}"
};
p.Start();
p.WaitForExit();
if (p.ExitCode != 0)

View file

@ -37,10 +37,10 @@ namespace Yavsc
using Yavsc.Services;
public partial class ChatHub : Hub, IDisposable
{
ApplicationDbContext _dbContext;
private IConnexionManager _cxManager;
private IStringLocalizer _localizer;
ILogger _logger;
private readonly ApplicationDbContext _dbContext;
private readonly IConnexionManager _cxManager;
private readonly IStringLocalizer _localizer;
private readonly ILogger _logger;
public HubInputValidator InputValidator { get; }

View file

@ -20,9 +20,9 @@ namespace Yavsc.Services
/// </summary>
public class HubConnectionManager : IConnexionManager
{
ILogger _logger;
private readonly ILogger _logger;
Action<string, string> _errorHandler;
private Action<string, string> _errorHandler;
/// <summary>
/// by cx id

View file

@ -28,23 +28,21 @@ namespace Yavsc.Services
return false;
}
}
UserMatch Out = new OutOfCircle();
UserMatch In = new BelongsToCircle();
readonly ApplicationDbContext _dbContext;
readonly ILogger _logger;
private readonly UserMatch Out = new OutOfCircle();
private readonly UserMatch In = new BelongsToCircle();
readonly SiteSettings SiteSettings;
private readonly ApplicationDbContext _dbContext;
readonly string aclfileName;
private readonly SiteSettings SiteSettings;
private readonly string aclfileName;
readonly RuleSetParser ruleSetParser;
public FileSystemAuthManager(ApplicationDbContext dbContext, ILoggerFactory loggerFactory,
IOptions<SiteSettings> sitesOptions)
public FileSystemAuthManager(ApplicationDbContext dbContext, IOptions<SiteSettings> sitesOptions)
{
_dbContext = dbContext;
_logger = loggerFactory.CreateLogger<FileSystemAuthManager>();
SiteSettings = sitesOptions.Value;
aclfileName = SiteSettings.AccessListFileName;
ruleSetParser = new RuleSetParser(false);

View file

@ -23,17 +23,12 @@ namespace Yavsc.Services
public class LiveProcessor : ILiveProcessor
{
readonly IHubContext _hubContext;
private readonly ILogger _logger;
readonly ApplicationDbContext _dbContext;
public ConcurrentDictionary<string, LiveCastHandler> Casters { get; } = new ConcurrentDictionary<string, LiveCastHandler>();
public LiveProcessor(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
public LiveProcessor(ILoggerFactory loggerFactory)
{
_dbContext = dbContext;
_hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
_logger = loggerFactory.CreateLogger<LiveProcessor>();
}

View file

@ -7,60 +7,58 @@ using Microsoft.Extensions.Logging;
namespace Yavsc
{
class YaSendFileWrapper : IHttpSendFileFeature
class YaSendFileWrapper : IHttpSendFileFeature
{
private readonly Stream _output;
private readonly ILogger _logger;
internal YaSendFileWrapper(Stream output, ILogger logger)
{
private readonly Stream _output;
_output = output;
_logger = logger;
}
private readonly ILogger _logger;
internal YaSendFileWrapper(Stream output, ILogger logger)
public async Task SendFileAsync(string fileName, long offset, long? length, CancellationToken cancel)
{
cancel.ThrowIfCancellationRequested();
if (string.IsNullOrWhiteSpace(fileName))
{
_output = output;
_logger = logger;
throw new ArgumentNullException("fileName");
}
public async Task SendFileAsync(string fileName, long offset, long? length, CancellationToken cancel)
if (!File.Exists(fileName))
{
cancel.ThrowIfCancellationRequested();
if (string.IsNullOrWhiteSpace(fileName))
{
throw new ArgumentNullException("fileName");
}
if (!File.Exists(fileName))
{
throw new FileNotFoundException(string.Empty, fileName);
}
FileInfo fileInfo = new FileInfo(fileName);
if (offset < 0 || offset > fileInfo.Length)
{
throw new ArgumentOutOfRangeException("offset", offset, string.Empty);
}
if (length.HasValue && (length.Value < 0 || length.Value > fileInfo.Length - offset))
{
throw new ArgumentOutOfRangeException("length", length, string.Empty);
}
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, maxbufferlen, FileOptions.Asynchronous | FileOptions.SequentialScan);
try
{
fileStream.Seek(offset, SeekOrigin.Begin);
_logger.LogInformation(string.Format("Copying bytes range:{0},{1} filename:{2} ", offset, (!length.HasValue) ? null : (offset + length), fileName));
// await CopyToAsync(fileStream, _output, length, cancel);
await CopyToAsync(fileStream, _output);
}
finally
{
fileStream.Dispose();
}
throw new FileNotFoundException(string.Empty, fileName);
}
FileInfo fileInfo = new FileInfo(fileName);
if (offset < 0 || offset > fileInfo.Length)
{
throw new ArgumentOutOfRangeException("offset", offset, string.Empty);
}
if (length.HasValue && (length.Value < 0 || length.Value > fileInfo.Length - offset))
{
throw new ArgumentOutOfRangeException("length", length, string.Empty);
}
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, maxbufferlen, FileOptions.Asynchronous | FileOptions.SequentialScan);
try
{
fileStream.Seek(offset, SeekOrigin.Begin);
_logger.LogInformation(string.Format("Copying bytes range:{0},{1} filename:{2} ", offset, (!length.HasValue) ? null : (offset + length), fileName));
// await CopyToAsync(fileStream, _output, length, cancel);
await CopyToAsync(fileStream, _output);
}
finally
{
fileStream.Dispose();
}
}
private const int maxbufferlen = 65536;
private byte[] buffer = new byte[maxbufferlen];
private async Task CopyToAsync(FileStream fileStream, Stream output)
{
await Task.Run(()=> fileStream.CopyTo(output, maxbufferlen));
await Task.Run(() => fileStream.CopyTo(output, maxbufferlen));
}
}
}

View file

@ -24,18 +24,5 @@ namespace Yavsc
app.UseSignalR(PathString.FromUriComponent(Constants.SignalRPath));
}
private async Task Echo(WebSocket webSocket)
{
var buffer = new byte[1024 * 4];
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
while (!result.CloseStatus.HasValue)
{
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
}
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
}
}
}

View file

@ -8,15 +8,12 @@ namespace Yavsc.ViewComponents
{
public class CalendarViewComponent : ViewComponent
{
readonly ApplicationDbContext _dbContext;
readonly ICalendarManager _manager;
public CalendarViewComponent (
ApplicationDbContext dbContext,
ICalendarManager manager)
{
_manager = manager;
_dbContext = dbContext;
}
public async Task<IViewComponentResult> InvokeAsync (

View file

@ -11,7 +11,7 @@ namespace Yavsc.ViewComponents
public class CirclesControlViewComponent : ViewComponent
{
ApplicationDbContext dbContext;
private readonly ApplicationDbContext dbContext;
public CirclesControlViewComponent(ApplicationDbContext dbContext)
{
this.dbContext = dbContext;

View file

@ -6,11 +6,10 @@ namespace Yavsc.ViewComponents
{
public partial class CommentViewComponent : ViewComponent
{
IStringLocalizer<CommentViewComponent> localizer;
private readonly IStringLocalizer<CommentViewComponent> localizer;
public CommentViewComponent(IStringLocalizer<CommentViewComponent> localizer)
{
this.localizer = localizer;
this.localizer = localizer;
}
public IViewComponentResult Invoke(IIdentified<long> longCommentable)
{
@ -19,4 +18,4 @@ namespace Yavsc.ViewComponents
return View(longCommentable.GetType().Name, new Comment{ PostId = longCommentable.Id });
}
}
}
}

View file

@ -7,15 +7,11 @@ using Yavsc.Models;
namespace Yavsc.ViewComponents
{
public class TaggerViewComponent : ViewComponent
{
readonly ApplicationDbContext dbContext;
{
readonly IStringLocalizer<TaggerViewComponent> localizer;
public TaggerViewComponent(
ApplicationDbContext pdbContext,
IStringLocalizer<TaggerViewComponent> pLocalizer)
{
dbContext = pdbContext;
this.localizer = pLocalizer;
}
public IViewComponentResult Invoke(ITaggable<long> longTaggable)