From c9d5c64f98c1f1fe7950de60c58edeaf3ace070d Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 27 Aug 2018 13:28:49 +0200 Subject: replace fs by fs-extra to prevent EMFILE error --- server/helpers/captions-utils.ts | 2 +- server/helpers/core-utils.ts | 3 +-- server/helpers/logger.ts | 4 ++-- server/helpers/requests.ts | 2 +- server/helpers/webtorrent.ts | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts index 8b04f878d..20c9fe5aa 100644 --- a/server/helpers/captions-utils.ts +++ b/server/helpers/captions-utils.ts @@ -3,7 +3,7 @@ import { join } from 'path' import { CONFIG } from '../initializers' import { VideoCaptionModel } from '../models/video/video-caption' import * as srt2vtt from 'srt-to-vtt' -import { createReadStream, createWriteStream } from 'fs' +import { createReadStream, createWriteStream } from 'fs-extra' async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) { const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 90d2cd9b3..9830d41a8 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -6,8 +6,7 @@ import * as bcrypt from 'bcrypt' import * as createTorrent from 'create-torrent' import { createHash, pseudoRandomBytes } from 'crypto' -import { copyFile, readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs' -import * as mkdirp from 'mkdirp' +import { copyFile, readdir, readFile, rename, stat, Stats, unlink, writeFile, mkdirp } from 'fs-extra' import { isAbsolute, join } from 'path' import * as pem from 'pem' import * as rimraf from 'rimraf' diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 480c5b49e..ce6e38f15 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts @@ -1,5 +1,5 @@ // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ -import * as mkdirp from 'mkdirp' +import { mkdirpSync } from 'fs-extra' import * as path from 'path' import * as winston from 'winston' import { CONFIG } from '../initializers' @@ -7,7 +7,7 @@ import { CONFIG } from '../initializers' const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT // Create the directory if it does not exist -mkdirp.sync(CONFIG.STORAGE.LOG_DIR) +mkdirpSync(CONFIG.STORAGE.LOG_DIR) function loggerReplacer (key: string, value: any) { if (value instanceof Error) { diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 64e3ce663..ee9e80404 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -1,5 +1,5 @@ import * as Bluebird from 'bluebird' -import { createWriteStream } from 'fs' +import { createWriteStream } from 'fs-extra' import * as request from 'request' import { ACTIVITY_PUB } from '../initializers' diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 6f2adb3cb..1c0d00d70 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts @@ -1,7 +1,7 @@ import { logger } from './logger' import { generateVideoTmpPath } from './utils' import * as WebTorrent from 'webtorrent' -import { createWriteStream } from 'fs' +import { createWriteStream } from 'fs-extra' import { CONFIG } from '../initializers' import { join } from 'path' import { unlinkPromise } from './core-utils' -- cgit v1.2.3