fix bug 60225

This commit is contained in:
pavelbannov 2022-12-25 19:05:03 +03:00
parent 8e5586e62a
commit 9f8ad6fb2a
3 changed files with 21 additions and 2 deletions

View File

@ -456,6 +456,15 @@ namespace ASC.Files.Core.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to The new version cannot be the same as the current one.
/// </summary>
public static string ErrorMassage_FileUpdateToVersion {
get {
return ResourceManager.GetString("ErrorMassage_FileUpdateToVersion", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You cannot copy the folder to its subfolder.
/// </summary>

View File

@ -249,6 +249,9 @@
<data name="ErrorMassage_FileSizeMove" xml:space="preserve">
<value>File larger than {0} will not be moved</value>
</data>
<data name="ErrorMassage_FileUpdateToVersion" xml:space="preserve">
<value>The new version cannot be the same as the current one</value>
</data>
<data name="ErrorMassage_FolderCopyError" xml:space="preserve">
<value>You cannot copy the folder to its subfolder</value>
</data>

View File

@ -1495,7 +1495,7 @@ public class EntryManager
}
}
public async Task<File<T>> UpdateToVersionFileAsync<T>(T fileId, int version, string doc = null, bool checkRight = true)
public async Task<File<T>> UpdateToVersionFileAsync<T>(T fileId, int version, string doc = null, bool checkRight = true, bool finalize = false)
{
var fileDao = _daoFactory.GetFileDao<T>();
if (version < 1)
@ -1519,6 +1519,13 @@ public class EntryManager
{
fromFile = await fileDao.GetFileAsync(fromFile.Id, Math.Min(fromFile.Version, version));
}
else
{
if (!finalize)
{
throw new Exception(FilesCommonResource.ErrorMassage_FileUpdateToVersion);
}
}
if (fromFile == null)
{
@ -1684,7 +1691,7 @@ public class EntryManager
{
if (fileVersion.Version == lastVersionFile.Version)
{
lastVersionFile = await UpdateToVersionFileAsync(fileVersion.Id, fileVersion.Version, null, checkRight);
lastVersionFile = await UpdateToVersionFileAsync(fileVersion.Id, fileVersion.Version, null, checkRight, true);
}
await fileDao.CompleteVersionAsync(fileVersion.Id, fileVersion.Version);