mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
nodejs: const declarations for variables that are never reassigned after declared
This commit is contained in:
@ -220,7 +220,7 @@ const checkFileInfo = function (wopi, req, res, userHost) {
|
||||
|
||||
const path = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
// add wopi query
|
||||
let query = new URLSearchParams(wopi.accessToken);
|
||||
const query = new URLSearchParams(wopi.accessToken);
|
||||
const user = users.getUser(query.get('userid'));
|
||||
|
||||
// create the file information object
|
||||
@ -241,7 +241,7 @@ const checkFileInfo = function (wopi, req, res, userHost) {
|
||||
|
||||
const saveFileFromBody = function (req, filename, userAddress, isNewVersion, callback) {
|
||||
if (req.body) {
|
||||
let storagePath = req.DocManager.storagePath(filename, userAddress);
|
||||
const storagePath = req.DocManager.storagePath(filename, userAddress);
|
||||
let historyPath = req.DocManager.historyPath(filename, userAddress); // get the path to the file history
|
||||
if (historyPath == '') { // if it is empty
|
||||
historyPath = req.DocManager.historyPath(filename, userAddress, true); // create it
|
||||
@ -250,14 +250,14 @@ const saveFileFromBody = function (req, filename, userAddress, isNewVersion, cal
|
||||
|
||||
let version = 0;
|
||||
if (isNewVersion) {
|
||||
let count_version = req.DocManager.countVersion(historyPath); // get the last file version
|
||||
const count_version = req.DocManager.countVersion(historyPath); // get the last file version
|
||||
version = count_version + 1; // get a number of a new file version
|
||||
// get the path to the specified file version
|
||||
let versionPath = req.DocManager.versionPath(filename, userAddress, version);
|
||||
const versionPath = req.DocManager.versionPath(filename, userAddress, version);
|
||||
req.DocManager.createDirectory(versionPath); // and create a new directory for the specified version
|
||||
|
||||
// get the path to the previous file version
|
||||
let path_prev = path.join(versionPath, `prev${fileUtility.getFileExtension(filename)}`);
|
||||
const path_prev = path.join(versionPath, `prev${fileUtility.getFileExtension(filename)}`);
|
||||
fileSystem.renameSync(storagePath, path_prev); // synchronously rename the given file as the previous file version
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
let lockDict = {};
|
||||
const lockDict = {};
|
||||
|
||||
// get the lock object of the specified file
|
||||
const getLockObject = function (filePath) {
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
|
||||
const config = require('config');
|
||||
const configServer = config.get('server');
|
||||
let urlModule = require('url');
|
||||
let urllib = require('urllib');
|
||||
const urlModule = require('url');
|
||||
const urllib = require('urllib');
|
||||
const xmlParser = require('fast-xml-parser');
|
||||
const he = require('he');
|
||||
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
|
||||
@ -59,7 +59,7 @@ const getDiscoveryInfo = async function (siteUrl) {
|
||||
const requestDiscovery = async function (siteUrl) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
return new Promise((resolve, reject) => {
|
||||
let actions = [];
|
||||
const actions = [];
|
||||
urllib.request(urlModule.parse(siteUrl + configServer.get('wopi.discovery')), {method: 'GET'}, (err, data) => {
|
||||
if (data) {
|
||||
// create the discovery XML file with the parameters from the response
|
||||
|
||||
@ -67,7 +67,7 @@ exports.registerRoutes = function (app) {
|
||||
const files = req.DocManager.getStoredFiles();
|
||||
|
||||
// run through all the files and write the corresponding information to each file
|
||||
for (let file of files) {
|
||||
for (const file of files) {
|
||||
const ext = fileUtility.getFileExtension(file.name, true); // get an extension of each file
|
||||
file.actions = await utils.getActions(ext); // get actions of the specified extension
|
||||
file.defaultAction = await utils.getDefaultAction(ext); // get the default action of the specified extension
|
||||
@ -95,13 +95,13 @@ exports.registerRoutes = function (app) {
|
||||
});
|
||||
// define a handler for creating a new wopi editing session
|
||||
app.get('/wopi-new', (req, res) => {
|
||||
let {fileExt} = req.query; // get the file extension from the request
|
||||
const {fileExt} = req.query; // get the file extension from the request
|
||||
|
||||
req.DocManager = new DocManager(req, res);
|
||||
|
||||
if (fileExt != null) { // if the file extension exists
|
||||
let fileName = req.DocManager.getCorrectName(`new.${fileExt}`)
|
||||
let redirectPath = `${req.DocManager.getServerUrl(true)}/wopi-action/`
|
||||
const fileName = req.DocManager.getCorrectName(`new.${fileExt}`)
|
||||
const redirectPath = `${req.DocManager.getServerUrl(true)}/wopi-action/`
|
||||
+ `${encodeURIComponent(fileName)}?action=editnew${req.DocManager.getCustomParams()}`; // get the redirect path
|
||||
res.redirect(redirectPath);
|
||||
return;
|
||||
@ -115,8 +115,8 @@ exports.registerRoutes = function (app) {
|
||||
await utils.initWopi(req.DocManager);
|
||||
|
||||
let fileName = req.DocManager.getCorrectName(req.params.id)
|
||||
let fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
|
||||
let user = users.getUser(req.query.userid); // get a user by the id
|
||||
const fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
|
||||
const user = users.getUser(req.query.userid); // get a user by the id
|
||||
|
||||
// get an action for the specified extension and name
|
||||
const action = await utils.getAction(fileExt, req.query.action);
|
||||
|
||||
Reference in New Issue
Block a user