mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 08:56:17 -04:00
lint: src/node/handler/ExportHandler.js
This commit is contained in:
parent
a7d9a703cd
commit
2fe5d1f873
1 changed files with 5 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
'use strict';
|
||||||
/**
|
/**
|
||||||
* Handles the export requests
|
* Handles the export requests
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +26,7 @@ const exportEtherpad = require('../utils/ExportEtherpad');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const settings = require('../utils/Settings');
|
const settings = require('../utils/Settings');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
const hooks = require('../../static/js/pluginfw/hooks');
|
||||||
const TidyHtml = require('../utils/TidyHtml');
|
const TidyHtml = require('../utils/TidyHtml');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ const tempDirectory = os.tmpdir();
|
||||||
/**
|
/**
|
||||||
* do a requested export
|
* do a requested export
|
||||||
*/
|
*/
|
||||||
async function doExport(req, res, padId, readOnlyId, type) {
|
const doExport = async (req, res, padId, readOnlyId, type) => {
|
||||||
// avoid naming the read-only file as the original pad's id
|
// avoid naming the read-only file as the original pad's id
|
||||||
let fileName = readOnlyId ? readOnlyId : padId;
|
let fileName = readOnlyId ? readOnlyId : padId;
|
||||||
|
|
||||||
|
@ -104,7 +105,6 @@ async function doExport(req, res, padId, readOnlyId, type) {
|
||||||
const result = await hooks.aCallAll('exportConvert', {srcFile, destFile, req, res});
|
const result = await hooks.aCallAll('exportConvert', {srcFile, destFile, req, res});
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
// console.log("export handled by plugin", destFile);
|
// console.log("export handled by plugin", destFile);
|
||||||
handledByPlugin = true;
|
|
||||||
} else {
|
} else {
|
||||||
// @TODO no Promise interface for convertors (yet)
|
// @TODO no Promise interface for convertors (yet)
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
@ -115,7 +115,6 @@ async function doExport(req, res, padId, readOnlyId, type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the file
|
// send the file
|
||||||
const sendFile = util.promisify(res.sendFile);
|
|
||||||
await res.sendFile(destFile, null);
|
await res.sendFile(destFile, null);
|
||||||
|
|
||||||
// clean up temporary files
|
// clean up temporary files
|
||||||
|
@ -128,9 +127,9 @@ async function doExport(req, res, padId, readOnlyId, type) {
|
||||||
|
|
||||||
await fsp_unlink(destFile);
|
await fsp_unlink(destFile);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.doExport = function (req, res, padId, readOnlyId, type) {
|
exports.doExport = (req, res, padId, readOnlyId, type) => {
|
||||||
doExport(req, res, padId, readOnlyId, type).catch((err) => {
|
doExport(req, res, padId, readOnlyId, type).catch((err) => {
|
||||||
if (err !== 'stop') {
|
if (err !== 'stop') {
|
||||||
throw err;
|
throw err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue