Merge pull request #892 from ONLYOFFICE/feature/local-restore
fix local restore
This commit is contained in:
commit
d5d78e7550
@ -22,8 +22,8 @@
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Data.Backup;
|
||||
|
||||
[Scope]
|
||||
@ -40,8 +40,9 @@ public class BackupAjaxHandler
|
||||
private readonly ConsumerFactory _consumerFactory;
|
||||
private readonly BackupService _backupService;
|
||||
private readonly TempPath _tempPath;
|
||||
private readonly StorageFactory _storageFactory;
|
||||
|
||||
private const string BackupTempFolder = "backup";
|
||||
private const string BackupTempModule = "backup_temp";
|
||||
private const string BackupFileName = "backup.tmp";
|
||||
|
||||
#region backup
|
||||
@ -57,7 +58,8 @@ public class BackupAjaxHandler
|
||||
UserManager userManager,
|
||||
TenantExtra tenantExtra,
|
||||
ConsumerFactory consumerFactory,
|
||||
TempPath tempPath)
|
||||
TempPath tempPath,
|
||||
StorageFactory storageFactory)
|
||||
{
|
||||
_tenantManager = tenantManager;
|
||||
_messageService = messageService;
|
||||
@ -69,7 +71,8 @@ public class BackupAjaxHandler
|
||||
_tenantExtra = tenantExtra;
|
||||
_consumerFactory = consumerFactory;
|
||||
_backupService = backupService;
|
||||
_tempPath = tempPath;
|
||||
_tempPath = tempPath;
|
||||
_storageFactory = storageFactory;
|
||||
}
|
||||
|
||||
public void StartBackup(BackupStorageType storageType, Dictionary<string, string> storageParams)
|
||||
@ -385,7 +388,8 @@ public class BackupAjaxHandler
|
||||
|
||||
public string GetTmpFilePath()
|
||||
{
|
||||
var folder = Path.Combine(_tempPath.GetTempPath(), BackupTempFolder, _tenantManager.GetCurrentTenant().Id.ToString());
|
||||
var discStore = _storageFactory.GetStorage("", _tenantManager.GetCurrentTenant().Id.ToString(), BackupTempModule, null) as DiscDataStore;
|
||||
var folder = discStore.GetPhysicalPath("", "");
|
||||
|
||||
if (!Directory.Exists(folder))
|
||||
{
|
||||
|
@ -27,8 +27,7 @@
|
||||
namespace ASC.Web.Studio.Core.Backup;
|
||||
|
||||
public class BackupFileUploadHandler
|
||||
{
|
||||
private const long MaxBackupFileSize = 1024L * 1024L * 1024L;
|
||||
{
|
||||
public BackupFileUploadHandler(RequestDelegate next)
|
||||
{
|
||||
|
||||
@ -53,12 +52,6 @@ public class BackupFileUploadHandler
|
||||
|
||||
var file = context.Request.Form.Files[0];
|
||||
|
||||
if (file.Length <= 0 || file.Length > MaxBackupFileSize)
|
||||
{
|
||||
result = Error($"File size must be greater than 0 and less than {MaxBackupFileSize} bytes");
|
||||
}
|
||||
|
||||
|
||||
var filePath = backupAjaxHandler.GetTmpFilePath();
|
||||
|
||||
if (File.Exists(filePath))
|
||||
|
@ -72,6 +72,7 @@ global using ASC.Data.Backup.Tasks.Modules;
|
||||
global using ASC.Data.Backup.Utils;
|
||||
global using ASC.Data.Storage;
|
||||
global using ASC.Data.Storage.Configuration;
|
||||
global using ASC.Data.Storage.DiscStorage;
|
||||
global using ASC.EventBus.Events;
|
||||
global using ASC.Files.Core;
|
||||
global using ASC.MessagingSystem.Core;
|
||||
@ -103,6 +104,5 @@ global using Microsoft.Extensions.Logging;
|
||||
global using MySql.Data.MySqlClient;
|
||||
|
||||
global using Newtonsoft.Json;
|
||||
global using Newtonsoft.Json.Linq;
|
||||
|
||||
global using ProtoBuf;
|
||||
|
@ -39,6 +39,7 @@ global using ASC.Data.Backup.ApiModels;
|
||||
global using ASC.Data.Backup.Contracts;
|
||||
global using ASC.Data.Backup.Core.IntegrationEvents.Events;
|
||||
global using ASC.Data.Backup.EF.Context;
|
||||
global using ASC.Data.Backup.Extension;
|
||||
global using ASC.Data.Backup.Services;
|
||||
global using ASC.EventBus.Abstractions;
|
||||
global using ASC.Files.Core.EF;
|
||||
@ -51,16 +52,12 @@ global using Autofac;
|
||||
|
||||
global using Microsoft.AspNetCore.Builder;
|
||||
global using Microsoft.AspNetCore.Hosting;
|
||||
global using Microsoft.AspNetCore.Http.Features;
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
global using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
global using Microsoft.Extensions.Configuration;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using Microsoft.Extensions.Hosting;
|
||||
global using Microsoft.Extensions.Hosting.WindowsServices;
|
||||
|
||||
global using static ASC.Data.Backup.BackupAjaxHandler;
|
||||
|
||||
global using ASC.Data.Backup.Extension;
|
||||
|
||||
global using NLog.Extensions.Logging;
|
||||
global using NLog.Web;
|
||||
global using NLog.AWS.Logger;
|
@ -22,8 +22,8 @@
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Data.Backup;
|
||||
|
||||
public class Startup : BaseStartup
|
||||
@ -38,6 +38,16 @@ public class Startup : BaseStartup
|
||||
{
|
||||
base.ConfigureServices(services);
|
||||
|
||||
var maxRequestLimit = 1024L * 1024L * 1024L;
|
||||
services.Configure<KestrelServerOptions>(options =>
|
||||
{
|
||||
options.Limits.MaxRequestBodySize = maxRequestLimit;
|
||||
});
|
||||
services.Configure<FormOptions>(x =>
|
||||
{
|
||||
x.MultipartBodyLengthLimit = maxRequestLimit;
|
||||
});
|
||||
|
||||
services.AddBaseDbContextPool<BackupsContext>();
|
||||
services.AddBaseDbContextPool<FilesDbContext>();
|
||||
|
||||
|
@ -249,6 +249,14 @@
|
||||
"virtualpath": "~/studio/{0}/backup",
|
||||
"expires": "0:10:0",
|
||||
"disableEncryption": true
|
||||
},
|
||||
{
|
||||
"name": "backup_temp",
|
||||
"visible": false,
|
||||
"type": "disc",
|
||||
"path": "$STORAGE_ROOT\\Studio\\{0}\\temp\\backup",
|
||||
"expires": "0:10:0",
|
||||
"disableEncryption": true
|
||||
},
|
||||
{
|
||||
"name": "customnavigation",
|
||||
|
Loading…
Reference in New Issue
Block a user