commit
13ec726ab2
|
@ -491,10 +491,15 @@ namespace Oqtane.Controllers
|
||||||
var filepath = _files.GetFilePath(file);
|
var filepath = _files.GetFilePath(file);
|
||||||
if (System.IO.File.Exists(filepath))
|
if (System.IO.File.Exists(filepath))
|
||||||
{
|
{
|
||||||
var result = asAttachment
|
if (asAttachment)
|
||||||
? PhysicalFile(filepath, file.GetMimeType(), file.Name)
|
{
|
||||||
: PhysicalFile(filepath, file.GetMimeType());
|
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.File, file.FileId, "Download");
|
||||||
return result;
|
return PhysicalFile(filepath, file.GetMimeType(), file.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PhysicalFile(filepath, file.GetMimeType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,12 +7,12 @@ using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
public class EventJob : IHostedService
|
public class CacheInvalidationHostedService : IHostedService
|
||||||
{
|
{
|
||||||
private readonly ISyncManager _syncManager;
|
private readonly ISyncManager _syncManager;
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
|
|
||||||
public EventJob(ISyncManager syncManager, IMemoryCache cache)
|
public CacheInvalidationHostedService(ISyncManager syncManager, IMemoryCache cache)
|
||||||
{
|
{
|
||||||
_syncManager = syncManager;
|
_syncManager = syncManager;
|
||||||
_cache = cache;
|
_cache = cache;
|
|
@ -23,15 +23,17 @@ namespace Oqtane.Pages
|
||||||
private readonly IFileRepository _files;
|
private readonly IFileRepository _files;
|
||||||
private readonly IUserPermissions _userPermissions;
|
private readonly IUserPermissions _userPermissions;
|
||||||
private readonly IUrlMappingRepository _urlMappings;
|
private readonly IUrlMappingRepository _urlMappings;
|
||||||
|
private readonly ISyncManager _syncManager;
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
private readonly Alias _alias;
|
private readonly Alias _alias;
|
||||||
|
|
||||||
public FilesModel(IWebHostEnvironment environment, IFileRepository files, IUserPermissions userPermissions, IUrlMappingRepository urlMappings, ILogManager logger, ITenantManager tenantManager)
|
public FilesModel(IWebHostEnvironment environment, IFileRepository files, IUserPermissions userPermissions, IUrlMappingRepository urlMappings, ISyncManager syncManager, ILogManager logger, ITenantManager tenantManager)
|
||||||
{
|
{
|
||||||
_environment = environment;
|
_environment = environment;
|
||||||
_files = files;
|
_files = files;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
_urlMappings = urlMappings;
|
_urlMappings = urlMappings;
|
||||||
|
_syncManager = syncManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_alias = tenantManager.GetAlias();
|
_alias = tenantManager.GetAlias();
|
||||||
}
|
}
|
||||||
|
@ -43,10 +45,9 @@ namespace Oqtane.Pages
|
||||||
var filename = "";
|
var filename = "";
|
||||||
|
|
||||||
bool download = false;
|
bool download = false;
|
||||||
if (path.Contains("?download"))
|
if (Request.Query.ContainsKey("download"))
|
||||||
{
|
{
|
||||||
download = true;
|
download = true;
|
||||||
path = path.Substring(0, path.IndexOf("?download"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var segments = path.Split('/');
|
var segments = path.Split('/');
|
||||||
|
@ -78,6 +79,7 @@ namespace Oqtane.Pages
|
||||||
{
|
{
|
||||||
if (download)
|
if (download)
|
||||||
{
|
{
|
||||||
|
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.File, file.FileId, "Download");
|
||||||
return PhysicalFile(filepath, file.GetMimeType(), file.Name);
|
return PhysicalFile(filepath, file.GetMimeType(), file.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user