mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
Merge branch hotfix/v5.6.0 into master
This commit is contained in:
@ -969,6 +969,11 @@ const c_oAscQueueType = {
|
||||
rabbitmq: 'rabbitmq',
|
||||
activemq: 'activemq'
|
||||
};
|
||||
const c_oAscUnlockRes = {
|
||||
Locked: 0,
|
||||
Unlocked: 1,
|
||||
Empty: 2
|
||||
};
|
||||
|
||||
const buildVersion = '4.1.2';
|
||||
const buildNumber = 37;
|
||||
@ -992,5 +997,6 @@ exports.c_oAscForceSaveTypes = c_oAscForceSaveTypes;
|
||||
exports.c_oAscUrlTypes = c_oAscUrlTypes;
|
||||
exports.c_oAscSecretType = c_oAscSecretType;
|
||||
exports.c_oAscQueueType = c_oAscQueueType;
|
||||
exports.c_oAscUnlockRes = c_oAscUnlockRes;
|
||||
exports.buildVersion = buildVersion;
|
||||
exports.buildNumber = buildNumber;
|
||||
|
||||
@ -1425,7 +1425,7 @@ exports.install = function(server, callbackFunction) {
|
||||
|
||||
if (unlock) {
|
||||
var unlockRes = yield editorData.unlockAuth(docId, userId);
|
||||
if (unlockRes) {
|
||||
if (commonDefines.c_oAscUnlockRes.Unlocked === unlockRes) {
|
||||
const participantsMap = yield* getParticipantMap(docId);
|
||||
yield* publish({
|
||||
type: commonDefines.c_oPublishType.auth,
|
||||
@ -1855,7 +1855,7 @@ exports.install = function(server, callbackFunction) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
upsertRes = yield canvasService.commandOpenStartPromise(docId, true, data.documentCallbackUrl, utils.getBaseUrlByConnection(conn));
|
||||
upsertRes = yield canvasService.commandOpenStartPromise(docId, utils.getBaseUrlByConnection(conn), true, data.documentCallbackUrl);
|
||||
curIndexUser = upsertRes.affectedRows == 1 ? 1 : upsertRes.insertId;
|
||||
}
|
||||
if (constants.CONN_CLOSED === conn.readyState) {
|
||||
@ -2459,7 +2459,7 @@ exports.install = function(server, callbackFunction) {
|
||||
// Снимаем лок с сохранения
|
||||
function* unSaveLock(conn, index, time) {
|
||||
var unlockRes = yield editorData.unlockSave(conn.docId, conn.user.id);
|
||||
if (unlockRes) {
|
||||
if (commonDefines.c_oAscUnlockRes.Locked !== unlockRes) {
|
||||
sendData(conn, {type: 'unSaveLock', index: index, time: time});
|
||||
} else {
|
||||
logger.warn("unSaveLock failure: docId = %s; conn.user.id: %s", conn.docId, conn.user.id);
|
||||
|
||||
@ -289,17 +289,16 @@ var cleanupCache = co.wrap(function* (docId) {
|
||||
return res;
|
||||
});
|
||||
|
||||
function commandOpenStartPromise(docId, opt_updateUserIndex, opt_documentCallbackUrl, opt_baseUrl) {
|
||||
function commandOpenStartPromise(docId, baseUrl, opt_updateUserIndex, opt_documentCallbackUrl) {
|
||||
var task = new taskResult.TaskResultData();
|
||||
task.key = docId;
|
||||
//None instead WaitQueue to prevent: conversion task is lost when entering and leaving the editor quickly(that leads to an endless opening)
|
||||
task.status = taskResult.FileStatus.None;
|
||||
task.statusInfo = constants.NO_ERROR;
|
||||
if (opt_documentCallbackUrl && opt_baseUrl) {
|
||||
task.baseurl = baseUrl;
|
||||
if (opt_documentCallbackUrl) {
|
||||
task.callback = opt_documentCallbackUrl;
|
||||
task.baseurl = opt_baseUrl;
|
||||
}
|
||||
|
||||
return taskResult.upsert(task, opt_updateUserIndex);
|
||||
}
|
||||
function* commandOpen(conn, cmd, outputData, opt_upsertRes, opt_bIsRestore) {
|
||||
@ -307,7 +306,7 @@ function* commandOpen(conn, cmd, outputData, opt_upsertRes, opt_bIsRestore) {
|
||||
if (opt_upsertRes) {
|
||||
upsertRes = opt_upsertRes;
|
||||
} else {
|
||||
upsertRes = yield commandOpenStartPromise(cmd.getDocId());
|
||||
upsertRes = yield commandOpenStartPromise(cmd.getDocId(), utils.getBaseUrlByConnection(conn));
|
||||
}
|
||||
//if CLIENT_FOUND_ROWS don't specify 1 row is inserted , 2 row is updated, and 0 row is set to its current values
|
||||
//http://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
|
||||
@ -781,6 +780,9 @@ function* commandSfcCallback(cmd, isSfcm, isEncrypted) {
|
||||
replyStr = yield* docsCoServer.sendServerRequest(docId, uri, outputSfc, checkAuthorizationLength);
|
||||
let replyData = docsCoServer.parseReplyData(docId, replyStr);
|
||||
isSfcmSuccess = replyData && commonDefines.c_oAscServerCommandErrors.NoError == replyData.error;
|
||||
if (replyData && commonDefines.c_oAscServerCommandErrors.NoError != replyData.error) {
|
||||
logger.warn('sendServerRequest returned an error: docId = %s; data = %s', docId, replyStr);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('sendServerRequest error: docId = %s;url = %s;data = %j\r\n%s', docId, uri, outputSfc, err.stack);
|
||||
}
|
||||
@ -811,7 +813,7 @@ function* commandSfcCallback(cmd, isSfcm, isEncrypted) {
|
||||
if (attempt < cfgCallbackBackoffOptions.retries) {
|
||||
needRetry = true;
|
||||
} else {
|
||||
logger.debug('commandSfcCallback backoff limit exceeded: docId = %s', docId);
|
||||
logger.warn('commandSfcCallback backoff limit exceeded: docId = %s', docId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -822,6 +824,9 @@ function* commandSfcCallback(cmd, isSfcm, isEncrypted) {
|
||||
var savedVal = yield docsCoServer.editorData.getdelSaved(docId);
|
||||
requestRes = (null == savedVal || '1' === savedVal);
|
||||
}
|
||||
if (replyData && commonDefines.c_oAscServerCommandErrors.NoError != replyData.error) {
|
||||
logger.warn('sendServerRequest returned an error: docId = %s; data = %s', docId, replyStr);
|
||||
}
|
||||
if (requestRes) {
|
||||
updateIfTask = undefined;
|
||||
yield docsCoServer.cleanDocumentOnExitPromise(docId, true);
|
||||
@ -852,7 +857,7 @@ function* commandSfcCallback(cmd, isSfcm, isEncrypted) {
|
||||
}
|
||||
if (storeForgotten && !needRetry && !isEncrypted && (!isError || isErrorCorrupted)) {
|
||||
try {
|
||||
logger.debug("storeForgotten: docId = %s", docId);
|
||||
logger.warn("storeForgotten: docId = %s", docId);
|
||||
let forgottenName = cfgForgottenFilesName + pathModule.extname(cmd.getOutputPath());
|
||||
yield storage.copyObject(savePathDoc, cfgForgottenFiles + '/' + docId + '/' + forgottenName);
|
||||
} catch (err) {
|
||||
@ -928,6 +933,9 @@ function* commandSendMMCallback(cmd) {
|
||||
outputMailMerge.setRecordErrorCount(recordErrorCount);
|
||||
mailMergeSendData.setRecordErrorCount(recordErrorCount);
|
||||
}
|
||||
if (replyData && commonDefines.c_oAscServerCommandErrors.NoError != replyData.error) {
|
||||
logger.warn('sendServerRequest returned an error: docId = %s; data = %s', docId, replyStr);
|
||||
}
|
||||
}
|
||||
var newRecordFrom = mailMergeSendData.getRecordFrom() + Math.max(files.length, 1);
|
||||
if (newRecordFrom <= mailMergeSendData.getRecordTo()) {
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
'use strict';
|
||||
const utils = require('./../../Common/sources/utils');
|
||||
const commonDefines = require('./../../Common/sources/commondefines');
|
||||
|
||||
function EditorData() {
|
||||
this.data = {};
|
||||
@ -63,10 +64,16 @@ EditorData.prototype._checkAndLock = function(name, docId, fencingToken, ttl) {
|
||||
EditorData.prototype._checkAndUnlock = function(name, docId, fencingToken) {
|
||||
let data = this._getDocumentData(docId);
|
||||
const now = Date.now();
|
||||
let res = true;
|
||||
if (data[name] && now < data[name].expireAt && fencingToken !== data[name].fencingToken) {
|
||||
res = false;
|
||||
let res;
|
||||
if (data[name] && now < data[name].expireAt) {
|
||||
if (fencingToken === data[name].fencingToken) {
|
||||
res = commonDefines.c_oAscUnlockRes.Unlocked;
|
||||
delete data[name];
|
||||
} else {
|
||||
res = commonDefines.c_oAscUnlockRes.Locked;
|
||||
}
|
||||
} else {
|
||||
res = commonDefines.c_oAscUnlockRes.Empty;
|
||||
delete data[name];
|
||||
}
|
||||
return Promise.resolve(res);
|
||||
|
||||
@ -87,8 +87,11 @@ exports.uploadTempFile = function(req, res) {
|
||||
});
|
||||
};
|
||||
function checkJwtUpload(docId, errorName, token){
|
||||
let checkJwtRes = docsCoServer.checkJwt(docId, token, commonDefines.c_oAscSecretType.Session);
|
||||
return checkJwtUploadTransformRes(docId, errorName, checkJwtRes);
|
||||
}
|
||||
function checkJwtUploadTransformRes(docId, errorName, checkJwtRes){
|
||||
var res = {err: true, docId: null, userid: null, encrypted: null};
|
||||
var checkJwtRes = docsCoServer.checkJwt(docId, token, commonDefines.c_oAscSecretType.Session);
|
||||
if (checkJwtRes.decoded) {
|
||||
var doc = checkJwtRes.decoded.document;
|
||||
var edit = checkJwtRes.decoded.editorConfig;
|
||||
@ -204,12 +207,12 @@ exports.uploadImageFile = function(req, res) {
|
||||
let checkJwtRes = docsCoServer.checkJwtHeader(docId, req, 'Authorization', 'Bearer ', commonDefines.c_oAscSecretType.Session);
|
||||
if (!checkJwtRes) {
|
||||
//todo remove compatibility with previous versions
|
||||
checkJwtRes = checkJwtUpload(docId, 'uploadImageFile', req.query['token']);
|
||||
checkJwtRes = docsCoServer.checkJwt(docId, req.query['token'], commonDefines.c_oAscSecretType.Session);
|
||||
}
|
||||
|
||||
if (!checkJwtRes.err) {
|
||||
docId = checkJwtRes.docId || docId;
|
||||
encrypted = checkJwtRes.encrypted;
|
||||
let transformedRes = checkJwtUploadTransformRes(docId, 'uploadImageFile', checkJwtRes);
|
||||
if (!transformedRes.err) {
|
||||
docId = transformedRes.docId || docId;
|
||||
encrypted = transformedRes.encrypted;
|
||||
} else {
|
||||
isValidJwt = false;
|
||||
}
|
||||
|
||||
@ -105,6 +105,10 @@ exports.upsert = function(task, opt_updateUserIndex) {
|
||||
let p10 = addSqlParam(JSON.stringify(task.callback), values);
|
||||
sqlCommand += `, callback = CONCAT(callback , '${sqlBase.UserCallback.prototype.delimiter}{"userIndex":' , (user_index + 1) , ',"callback":', ${p10}, '}')`;
|
||||
}
|
||||
if (task.baseurl) {
|
||||
let p11 = addSqlParam(task.baseurl, values);
|
||||
sqlCommand += `, baseurl = ${p11}`;
|
||||
}
|
||||
if (opt_updateUserIndex) {
|
||||
sqlCommand += ', user_index = LAST_INSERT_ID(user_index + 1)';
|
||||
}
|
||||
|
||||
@ -125,6 +125,10 @@ function getUpsertString(task, values) {
|
||||
sqlCommand += `, callback = task_result.callback || '${sqlBase.UserCallback.prototype.delimiter}{"userIndex":' `;
|
||||
sqlCommand += ` || (task_result.user_index + 1)::text || ',"callback":' || ${p10}::text || '}'`;
|
||||
}
|
||||
if (task.baseurl) {
|
||||
let p11 = addSqlParam(task.baseurl, values);
|
||||
sqlCommand += `, baseurl = ${p11}`;
|
||||
}
|
||||
sqlCommand += ", user_index = task_result.user_index + 1 RETURNING user_index as userindex;";
|
||||
return sqlCommand;
|
||||
} else {
|
||||
|
||||
@ -127,7 +127,7 @@ if (configStorage.has('fs.folderPath')) {
|
||||
try {
|
||||
fs.watch(config.get('plugins.path'), updatePlugins);
|
||||
} catch (e) {
|
||||
logger.warn('Plugins watch exception (https://nodejs.org/docs/latest/api/fs.html#fs_availability).');
|
||||
logger.warn('Failed to subscribe to plugin folder updates. When changing the list of plugins, you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability');
|
||||
}
|
||||
fs.watchFile(configCommon.get('license').get('license_file'), updateLicense);
|
||||
setInterval(updateLicense, 86400000);
|
||||
|
||||
Reference in New Issue
Block a user