diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:23:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:23:34 +0200 |
commit | 62689b942b71cd1dd0d050c6ed05f884a0b325c2 (patch) | |
tree | c45c35d35d7a3e32621fba06edc63646930c8efd /server/lib | |
parent | 84b6dbcc6e8654f39ec798905e1151ba915cd1aa (diff) | |
download | PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.gz PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.zst PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.zip |
Correctly migrate to fs-extra
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/cache/abstract-video-static-file-cache.ts | 5 | ||||
-rw-r--r-- | server/lib/client-html.ts | 7 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 6 | ||||
-rw-r--r-- | server/lib/schedulers/youtube-dl-update-scheduler.ts | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/server/lib/cache/abstract-video-static-file-cache.ts b/server/lib/cache/abstract-video-static-file-cache.ts index 3e20c5d2a..7512f2b9d 100644 --- a/server/lib/cache/abstract-video-static-file-cache.ts +++ b/server/lib/cache/abstract-video-static-file-cache.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import * as AsyncLRU from 'async-lru' | 1 | import * as AsyncLRU from 'async-lru' |
2 | import { createWriteStream } from 'fs-extra' | 2 | import { createWriteStream, remove } from 'fs-extra' |
3 | import { unlinkPromise } from '../../helpers/core-utils' | ||
4 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
5 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
6 | import { fetchRemoteVideoStaticFile } from '../activitypub' | 5 | import { fetchRemoteVideoStaticFile } from '../activitypub' |
@@ -26,7 +25,7 @@ export abstract class AbstractVideoStaticFileCache <T> { | |||
26 | }) | 25 | }) |
27 | 26 | ||
28 | this.lru.on('evict', (obj: { key: string, value: string }) => { | 27 | this.lru.on('evict', (obj: { key: string, value: string }) => { |
29 | unlinkPromise(obj.value) | 28 | remove(obj.value) |
30 | .then(() => logger.debug('%s evicted from %s', obj.value, this.constructor.name)) | 29 | .then(() => logger.debug('%s evicted from %s', obj.value, this.constructor.name)) |
31 | }) | 30 | }) |
32 | } | 31 | } |
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 72984e778..a69e09c32 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as Bluebird from 'bluebird' | 2 | import * as Bluebird from 'bluebird' |
3 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' | 3 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' |
4 | import { CONFIG, EMBED_SIZE, CUSTOM_HTML_TAG_COMMENTS, STATIC_PATHS } from '../initializers' | 4 | import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, STATIC_PATHS } from '../initializers' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { escapeHTML, readFileBufferPromise } from '../helpers/core-utils' | 6 | import { escapeHTML } from '../helpers/core-utils' |
7 | import { VideoModel } from '../models/video/video' | 7 | import { VideoModel } from '../models/video/video' |
8 | import * as validator from 'validator' | 8 | import * as validator from 'validator' |
9 | import { VideoPrivacy } from '../../shared/models/videos' | 9 | import { VideoPrivacy } from '../../shared/models/videos' |
10 | import { readFile } from 'fs-extra' | ||
10 | 11 | ||
11 | export class ClientHtml { | 12 | export class ClientHtml { |
12 | 13 | ||
@@ -20,7 +21,7 @@ export class ClientHtml { | |||
20 | const path = ClientHtml.getIndexPath(req, res, paramLang) | 21 | const path = ClientHtml.getIndexPath(req, res, paramLang) |
21 | if (ClientHtml.htmlCache[path]) return ClientHtml.htmlCache[path] | 22 | if (ClientHtml.htmlCache[path]) return ClientHtml.htmlCache[path] |
22 | 23 | ||
23 | const buffer = await readFileBufferPromise(path) | 24 | const buffer = await readFile(path) |
24 | 25 | ||
25 | let html = buffer.toString() | 26 | let html = buffer.toString() |
26 | 27 | ||
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index d6984ef92..ebcb2090c 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -6,7 +6,6 @@ import { VideoImportState } from '../../../../shared/models/videos' | |||
6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
7 | import { extname, join } from 'path' | 7 | import { extname, join } from 'path' |
8 | import { VideoFileModel } from '../../../models/video/video-file' | 8 | import { VideoFileModel } from '../../../models/video/video-file' |
9 | import { renamePromise, statPromise, unlinkPromise } from '../../../helpers/core-utils' | ||
10 | import { CONFIG, sequelizeTypescript } from '../../../initializers' | 9 | import { CONFIG, sequelizeTypescript } from '../../../initializers' |
11 | import { doRequestAndSaveToFile } from '../../../helpers/requests' | 10 | import { doRequestAndSaveToFile } from '../../../helpers/requests' |
12 | import { VideoState } from '../../../../shared' | 11 | import { VideoState } from '../../../../shared' |
@@ -15,6 +14,7 @@ import { federateVideoIfNeeded } from '../../activitypub' | |||
15 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
16 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
17 | import { getSecureTorrentName } from '../../../helpers/utils' | 16 | import { getSecureTorrentName } from '../../../helpers/utils' |
17 | import { rename, stat } from 'fs-extra' | ||
18 | 18 | ||
19 | type VideoImportYoutubeDLPayload = { | 19 | type VideoImportYoutubeDLPayload = { |
20 | type: 'youtube-dl' | 20 | type: 'youtube-dl' |
@@ -114,7 +114,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide | |||
114 | tempVideoPath = await downloader() | 114 | tempVideoPath = await downloader() |
115 | 115 | ||
116 | // Get information about this video | 116 | // Get information about this video |
117 | const stats = await statPromise(tempVideoPath) | 117 | const stats = await stat(tempVideoPath) |
118 | const isAble = await videoImport.User.isAbleToUploadVideo({ size: stats.size }) | 118 | const isAble = await videoImport.User.isAbleToUploadVideo({ size: stats.size }) |
119 | if (isAble === false) { | 119 | if (isAble === false) { |
120 | throw new Error('The user video quota is exceeded with this video to import.') | 120 | throw new Error('The user video quota is exceeded with this video to import.') |
@@ -138,7 +138,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide | |||
138 | 138 | ||
139 | // Move file | 139 | // Move file |
140 | videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile)) | 140 | videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile)) |
141 | await renamePromise(tempVideoPath, videoDestFile) | 141 | await rename(tempVideoPath, videoDestFile) |
142 | tempVideoPath = null // This path is not used anymore | 142 | tempVideoPath = null // This path is not used anymore |
143 | 143 | ||
144 | // Process thumbnail | 144 | // Process thumbnail |
diff --git a/server/lib/schedulers/youtube-dl-update-scheduler.ts b/server/lib/schedulers/youtube-dl-update-scheduler.ts index da47378e8..faadb4334 100644 --- a/server/lib/schedulers/youtube-dl-update-scheduler.ts +++ b/server/lib/schedulers/youtube-dl-update-scheduler.ts | |||
@@ -5,9 +5,9 @@ import { AbstractScheduler } from './abstract-scheduler' | |||
5 | import { SCHEDULER_INTERVALS_MS } from '../../initializers' | 5 | import { SCHEDULER_INTERVALS_MS } from '../../initializers' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import * as request from 'request' | 7 | import * as request from 'request' |
8 | import { createWriteStream, writeFile } from 'fs-extra' | 8 | import { createWriteStream, ensureDir, writeFile } from 'fs-extra' |
9 | import { join } from 'path' | 9 | import { join } from 'path' |
10 | import { mkdirpPromise, root } from '../../helpers/core-utils' | 10 | import { root } from '../../helpers/core-utils' |
11 | 11 | ||
12 | export class YoutubeDlUpdateScheduler extends AbstractScheduler { | 12 | export class YoutubeDlUpdateScheduler extends AbstractScheduler { |
13 | 13 | ||
@@ -27,7 +27,7 @@ export class YoutubeDlUpdateScheduler extends AbstractScheduler { | |||
27 | const detailsPath = join(binDirectory, 'details') | 27 | const detailsPath = join(binDirectory, 'details') |
28 | const url = 'https://yt-dl.org/downloads/latest/youtube-dl' | 28 | const url = 'https://yt-dl.org/downloads/latest/youtube-dl' |
29 | 29 | ||
30 | await mkdirpPromise(binDirectory) | 30 | await ensureDir(binDirectory) |
31 | 31 | ||
32 | return new Promise(res => { | 32 | return new Promise(res => { |
33 | request.get(url, { followRedirect: false }, (err, result) => { | 33 | request.get(url, { followRedirect: false }, (err, result) => { |