Skip to content

Commit

Permalink
fixed expiration date setting for primary file link
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksimChegulov committed Nov 14, 2024
1 parent c626c15 commit e5c6597
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions products/ASC.Files/Core/Core/FileStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,8 @@ public async Task<AceWrapper> GetPrimaryExternalLinkAsync<T>(
DateTime expirationDate = default,
bool denyDownload = false,
bool requiredAuth = false,
string password = null)
string password = null,
bool allowUnlimitedDate = false)
{
var fileDao = daoFactory.GetFileDao<T>();
var folderDao = daoFactory.GetFolderDao<T>();
Expand Down Expand Up @@ -3188,7 +3189,7 @@ public async Task<AceWrapper> GetPrimaryExternalLinkAsync<T>(
primary: true,
expirationDate: expirationDate != default
? expirationDate
: entry.RootFolderType == FolderType.USER ? DateTime.UtcNow.Add(filesLinkUtility.DefaultLinkLifeTime) : default,
: entry.RootFolderType == FolderType.USER && !allowUnlimitedDate ? DateTime.UtcNow.Add(filesLinkUtility.DefaultLinkLifeTime) : default,
denyDownload: denyDownload,
requiredAuth: requiredAuth,
password: password);
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Server/Api/FilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public async Task<FileDto<T>> UpdateFileStreamFromFormAsync(FileStreamRequestDto
[HttpPost("file/{id}/link")]
public async Task<FileShareDto> CreatePrimaryExternalLinkAsync(FileLinkRequestDto<T> inDto)
{
var linkAce = await fileStorageService.GetPrimaryExternalLinkAsync(inDto.Id, FileEntryType.File, inDto.File.Access, expirationDate: inDto.File.ExpirationDate, requiredAuth: inDto.File.Internal);
var linkAce = await fileStorageService.GetPrimaryExternalLinkAsync(inDto.Id, FileEntryType.File, inDto.File.Access, expirationDate: inDto.File.ExpirationDate, requiredAuth: inDto.File.Internal, allowUnlimitedDate: true);
return await fileShareDtoHelper.Get(linkAce);
}

Expand Down

0 comments on commit e5c6597

Please sign in to comment.