diff --git a/build/build.backend.bat b/build/build.backend.bat index d84130726f..a0b36d3589 100644 --- a/build/build.backend.bat +++ b/build/build.backend.bat @@ -1,6 +1,7 @@ +@echo off + PUSHD %~dp0.. dotnet build ASC.Web.slnf /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal -@echo off echo. echo Install nodejs projects dependencies... echo. @@ -15,6 +16,8 @@ if %errorlevel% == 0 ( echo. +POPD + if "%1"=="nopause" goto start pause :start \ No newline at end of file diff --git a/build/build.bat b/build/build.bat index a6afe940db..868b4eb304 100644 --- a/build/build.bat +++ b/build/build.bat @@ -1,18 +1,27 @@ +@echo off + +echo "##########################################################" +echo "######### Start build and deploy #######################" +echo "##########################################################" + +echo. + PUSHD %~dp0 call runasadmin.bat "%~dpnx0" + if %errorlevel% == 0 ( -call start\stop.bat - -PUSHD %~dp0.. +call start\stop.bat nopause echo "FRONT-END (for start run command 'yarn start' inside the root folder)" -call build\build.frontend.bat +call build.frontend.bat nopause echo "BACK-END" -call build\build.backend.bat +call build.backend.bat nopause -start /b call build\start\start.bat +call start\start.bat nopause + +echo. pause ) \ No newline at end of file diff --git a/build/build.static.bat b/build/build.static.bat index f0a4cfebf8..6d6b2c4df8 100644 --- a/build/build.static.bat +++ b/build/build.static.bat @@ -48,15 +48,24 @@ powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-studio.conf REM restart nginx echo service nginx stop -call sc stop nginx +call sc stop nginx > nul REM sleep 5 seconds call ping 127.0.0.1 -n 6 > nul echo service nginx start -call sc start nginx +call sc start nginx > nul + +if NOT %errorlevel% == 0 ( + echo Couldn't restarte Onlyoffice%%~nf service ) +) + +echo. + +POPD + if "%1"=="nopause" goto start pause :start \ No newline at end of file diff --git a/build/buildAndDeploy.PERSONAL.bat b/build/buildAndDeploy.PERSONAL.bat index aa1b1e7b1e..d89a6d053a 100644 --- a/build/buildAndDeploy.PERSONAL.bat +++ b/build/buildAndDeploy.PERSONAL.bat @@ -1,3 +1,9 @@ +echo "##########################################################" +echo "######### Start build and deploy Personal ##############" +echo "##########################################################" + +echo. + PUSHD %~dp0 call runasadmin.bat "%~dpnx0" if %errorlevel% == 0 ( diff --git a/build/buildAndDeploy.bat b/build/buildAndDeploy.bat index 64927a481c..af3f52ca0a 100644 --- a/build/buildAndDeploy.bat +++ b/build/buildAndDeploy.bat @@ -1,5 +1,11 @@ @echo off -PUSHD %~dp0 + +echo "##########################################################" +echo "######### Start build and deploy #######################" +echo "##########################################################" + +echo. + setlocal EnableDelayedExpansion call runasadmin.bat "%~dpnx0" @@ -8,15 +14,15 @@ if %errorlevel% == 0 ( call start\stop.bat nopause -PUSHD %~dp0.. - echo "FRONT-END static" -call build\build.static.bat nopause +call build.static.bat nopause echo "BACK-END" -call build\build.backend.bat nopause +call build.backend.bat nopause -call build\start\start.bat nopause +call start\start.bat nopause + +echo. pause ) \ No newline at end of file diff --git a/build/runasadmin.bat b/build/runasadmin.bat index 73b0a1958d..6298efa01b 100644 --- a/build/runasadmin.bat +++ b/build/runasadmin.bat @@ -23,6 +23,5 @@ if '%errorlevel%' NEQ '0' ( exit /B 1 :gotAdmin - pushd "%CD%" CD /D "%~dp0" :-------------------------------------- \ No newline at end of file diff --git a/build/start/command.ps1 b/build/start/command.ps1 new file mode 100644 index 0000000000..8eef959102 --- /dev/null +++ b/build/start/command.ps1 @@ -0,0 +1,33 @@ +$PSversionMajor = $PSVersionTable.PSVersion | sort-object major | ForEach-Object {$_.major} +$PSversionMinor = $PSVersionTable.PSVersion | sort-object minor | ForEach-Object {$_.minor} + +if ($PSversionMajor -lt 7 -or $PSversionMinor -lt 2) { + Write-Error "Powershell version must be greater than or equal to 7.2. Press Enter to exit." + Pause + exit +} + +$WorkDir = "$(Split-Path -Parent $PSScriptRoot)\run"; +$CommandName = "$($args[0])"; + +#Write-Output "Starting $($CommandName) services at time: $(Get-Date -Format HH:mm:ss)" +#Write-Output "" + +Get-ChildItem -Path $WorkDir | ForEach-Object -ThrottleLimit 20 -Parallel { + $ServiceName = "Onlyoffice$([System.IO.Path]::GetFileNameWithoutExtension($_))"; + + switch ( $Using:CommandName ) + { + "start" { Start-Service -InputObject $(Get-Service -Name "$ServiceName") } + "stop" { Stop-Service -InputObject $(Get-Service -Name "$ServiceName") } + "restart" { Restart-Service -InputObject $(Get-Service -Name "$ServiceName") } + } + + if( $? ) + { + Write-Output "$ServiceName $($Using:CommandName) service has been done" + } +} + +#Write-Output "" +#Write-Output "End $($CommandName) services at time: $(Get-Date -Format HH:mm:ss)" \ No newline at end of file diff --git a/build/start/restart.bat b/build/start/restart.bat index 256665750f..7a3bbff722 100644 --- a/build/start/restart.bat +++ b/build/start/restart.bat @@ -3,11 +3,10 @@ PUSHD %~dp0.. call runasadmin.bat "%~dpnx0" +POPD + if %errorlevel% == 0 ( - for /R "run\" %%f in (*.bat) do ( - call sc stop "Onlyoffice%%~nf" - call sc start "Onlyoffice%%~nf" - ) + pwsh %~dp0/command.ps1 "restart" ) echo. diff --git a/build/start/start.bat b/build/start/start.bat index 9ecf6aa69e..66ddb75db4 100644 --- a/build/start/start.bat +++ b/build/start/start.bat @@ -3,10 +3,10 @@ PUSHD %~dp0.. call runasadmin.bat "%~dpnx0" +POPD + if %errorlevel% == 0 ( - for /R "run\" %%f in (*.bat) do ( - call sc start "Onlyoffice%%~nf" - ) + pwsh %~dp0/command.ps1 "start" ) echo. diff --git a/build/start/stop.bat b/build/start/stop.bat index b28a9c758f..61fccbb9e9 100644 --- a/build/start/stop.bat +++ b/build/start/stop.bat @@ -3,10 +3,10 @@ PUSHD %~dp0.. call runasadmin.bat "%~dpnx0" +POPD + if %errorlevel% == 0 ( - for /R "run\" %%f in (*.bat) do ( - call sc stop "Onlyoffice%%~nf" - ) + pwsh %~dp0/command.ps1 "stop" ) echo. diff --git a/products/ASC.Files/Core/Core/Security/FileSecurity.cs b/products/ASC.Files/Core/Core/Security/FileSecurity.cs index 20c5b58876..8da56a2d79 100644 --- a/products/ASC.Files/Core/Core/Security/FileSecurity.cs +++ b/products/ASC.Files/Core/Core/Security/FileSecurity.cs @@ -205,7 +205,8 @@ namespace ASC.Files.Core.Security private IEnumerable WhoCan(FileEntry entry, FilesSecurityActions action) { - var shares = GetShares(entry); + var copyshares = GetShares(entry); + IEnumerable shares = copyshares.ToList(); FileShareRecord defaultShareRecord; @@ -318,7 +319,7 @@ namespace ASC.Files.Core.Security return new[] { x.Subject }; }) .Distinct() - .Where(x => Can(entry, x, action)) + .Where(x => Can(entry, x, action, copyshares)) .ToList(); } @@ -342,9 +343,9 @@ namespace ASC.Files.Core.Security return Filter(entries.Cast>(), FilesSecurityActions.Edit, AuthContext.CurrentAccount.ID).Cast>(); } - private bool Can(FileEntry entry, Guid userId, FilesSecurityActions action) + private bool Can(FileEntry entry, Guid userId, FilesSecurityActions action, IEnumerable shares = null) { - return Filter(new[] { entry }, action, userId).Any(); + return Filter(new[] { entry }, action, userId, shares).Any(); } private List, bool>> Can(IEnumerable> entry, Guid userId, FilesSecurityActions action) @@ -353,7 +354,7 @@ namespace ASC.Files.Core.Security return entry.Select(r => new Tuple, bool>(r, filtres.Any(a => a.ID.Equals(r.ID)))).ToList(); } - private IEnumerable> Filter(IEnumerable> entries, FilesSecurityActions action, Guid userId) + private IEnumerable> Filter(IEnumerable> entries, FilesSecurityActions action, Guid userId, IEnumerable shares = null) { if (entries == null || !entries.Any()) return Enumerable.Empty>(); @@ -383,8 +384,7 @@ namespace ASC.Files.Core.Security if (entries.Any(filter)) { - var subjects = GetUserSubjects(userId); - List shares = null; + List subjects = null; foreach (var e in entries.Where(filter)) { if (!AuthManager.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, userId).IsAuthenticated && userId != FileConstant.ShareLinkId) @@ -514,12 +514,19 @@ namespace ASC.Files.Core.Security // administrator in Common has all right result.Add(e); continue; - } + } - if (shares == null) - { - shares = GetShares(entries).Join(subjects, r => r.Subject, s => s, (r, s) => r).ToList(); - // shares ordered by level + if (subjects == null) + { + subjects = GetUserSubjects(userId); + if (shares == null) + { + shares = GetShares(entries); + // shares ordered by level + } + shares = shares + .Join(subjects, r => r.Subject, s => s, (r, s) => r) + .ToList(); } FileShareRecord ace; @@ -705,7 +712,7 @@ namespace ASC.Files.Core.Security var records = securityDao.GetShares(subjects); var result = new List(); - result.AddRange(GetSharesForMe(records.Where(r=> r.EntryId.GetType() == typeof(int)), subjects, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders)); + result.AddRange(GetSharesForMe(records.Where(r => r.EntryId.GetType() == typeof(int)), subjects, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders)); result.AddRange(GetSharesForMe(records.Where(r => r.EntryId.GetType() == typeof(string)), subjects, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders)); return result; }