"redis": "^2.8.0",
"reflect-metadata": "^0.1.10",
"request": "^2.81.0",
- "rimraf": "^2.5.4",
"safe-buffer": "^5.0.1",
"scripty": "^1.5.0",
"sequelize": "4.38.0",
"@types/config": "^0.0.34",
"@types/express": "^4.0.35",
"@types/express-rate-limit": "^2.9.3",
+ "@types/fs-extra": "^5.0.4",
"@types/libxmljs": "^0.18.0",
"@types/lodash": "^4.14.64",
"@types/magnet-uri": "^5.1.1",
import * as prompt from 'prompt'
import { join } from 'path'
-import { readdirPromise, unlinkPromise } from '../server/helpers/core-utils'
import { CONFIG } from '../server/initializers/constants'
import { VideoModel } from '../server/models/video/video'
import { initDatabaseModels } from '../server/initializers'
+import { remove, readdir } from 'fs-extra'
run()
.then(() => process.exit(0))
console.log('Processing delete...\n')
for (const path of toDelete) {
- await unlinkPromise(path)
+ await remove(path)
}
console.log('Done!')
}
async function pruneDirectory (directory: string) {
- const files = await readdirPromise(directory)
+ const files = await readdir(directory)
const toDelete: string[] = []
for (const file of files) {
import { ServerConfig, UserRight } from '../../../shared'
import { About } from '../../../shared/models/server/about.model'
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
-import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils'
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers'
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
import { ClientHtml } from '../../lib/client-html'
import { auditLoggerFactory, CustomConfigAuditView } from '../../helpers/audit-logger'
+import { remove, writeJSON } from 'fs-extra'
const packageJSON = require('../../../../package.json')
const configRouter = express.Router()
}
async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
- await unlinkPromise(CONFIG.CUSTOM_FILE)
+ await remove(CONFIG.CUSTOM_FILE)
auditLogger.delete(
res.locals.oauth.token.User.Account.Actor.getIdentifier(),
toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription
toUpdateJSON.instance['default_nsfw_policy'] = toUpdate.instance.defaultNSFWPolicy
- await writeFilePromise(CONFIG.CUSTOM_FILE, JSON.stringify(toUpdateJSON, undefined, 2))
+ await writeJSON(CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 })
reloadConfig()
ClientHtml.invalidCache()
import { VideoChannelModel } from '../../../models/video/video-channel'
import * as Bluebird from 'bluebird'
import * as parseTorrent from 'parse-torrent'
-import { readFileBufferPromise, renamePromise } from '../../../helpers/core-utils'
import { getSecureTorrentName } from '../../../helpers/utils'
+import { readFile, rename } from 'fs-extra'
const auditLogger = auditLoggerFactory('video-imports')
const videoImportsRouter = express.Router()
// Rename the torrent to a secured name
const newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName))
- await renamePromise(torrentfile.path, newTorrentPath)
+ await rename(torrentfile.path, newTorrentPath)
torrentfile.path = newTorrentPath
- const buf = await readFileBufferPromise(torrentfile.path)
+ const buf = await readFile(torrentfile.path)
const parsedTorrent = parseTorrent(buf)
videoName = isArray(parsedTorrent.name) ? parsedTorrent.name[ 0 ] : parsedTorrent.name as string
import * as express from 'express'
import { extname, join } from 'path'
import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared'
-import { renamePromise } from '../../../helpers/core-utils'
import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
import { processImage } from '../../../helpers/image-utils'
import { logger } from '../../../helpers/logger'
import { videoCaptionsRouter } from './captions'
import { videoImportsRouter } from './import'
import { resetSequelizeInstance } from '../../../helpers/database-utils'
+import { rename } from 'fs-extra'
const auditLogger = auditLoggerFactory('videos')
const videosRouter = express.Router()
// Move physical file
const videoDir = CONFIG.STORAGE.VIDEOS_DIR
const destination = join(videoDir, video.getVideoFilename(videoFile))
- await renamePromise(videoPhysicalFile.path, destination)
+ await rename(videoPhysicalFile.path, destination)
// This is important in case if there is another attempt in the retry process
videoPhysicalFile.filename = video.getVideoFilename(videoFile)
videoPhysicalFile.path = destination
-import { renamePromise, unlinkPromise } from './core-utils'
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-extra'
+import { createReadStream, createWriteStream, remove, rename } from 'fs-extra'
async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) {
const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
// Convert this srt file to vtt
if (physicalFile.path.endsWith('.srt')) {
await convertSrtToVtt(physicalFile.path, destination)
- await unlinkPromise(physicalFile.path)
+ await remove(physicalFile.path)
} else { // Just move the vtt file
- await renamePromise(physicalFile.path, destination)
+ await rename(physicalFile.path, destination)
}
// This is important in case if there is another attempt in the retry process
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, mkdirp } from 'fs-extra'
import { isAbsolute, join } from 'path'
import * as pem from 'pem'
import * as rimraf from 'rimraf'
}
}
-const copyFilePromise = promisify2WithVoid<string, string>(copyFile)
-const readFileBufferPromise = promisify1<string, Buffer>(readFile)
-const unlinkPromise = promisify1WithVoid<string>(unlink)
-const renamePromise = promisify2WithVoid<string, string>(rename)
-const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
-const readdirPromise = promisify1<string, string[]>(readdir)
-const mkdirpPromise = promisify1<string, string>(mkdirp)
-// we cannot modify the Promise types, so we should make the promisify instance check mkdirp
const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey)
const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey)
const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
const createTorrentPromise = promisify2<string, any, any>(createTorrent)
-const rimrafPromise = promisify1WithVoid<string>(rimraf)
-const statPromise = promisify1<string, Stats>(stat)
// ---------------------------------------------------------------------------
promisify0,
promisify1,
- copyFilePromise,
- readdirPromise,
- readFileBufferPromise,
- unlinkPromise,
- renamePromise,
- writeFilePromise,
- mkdirpPromise,
pseudoRandomBytesPromise,
createPrivateKey,
getPublicKey,
bcryptComparePromise,
bcryptGenSaltPromise,
bcryptHashPromise,
- createTorrentPromise,
- rimrafPromise,
- statPromise
+ createTorrentPromise
}
import * as ffmpeg from 'fluent-ffmpeg'
import { join } from 'path'
import { VideoResolution } from '../../shared/models/videos'
-import { CONFIG, VIDEO_TRANSCODING_FPS, FFMPEG_NICE } from '../initializers'
-import { unlinkPromise } from './core-utils'
+import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers'
import { processImage } from './image-utils'
import { logger } from './logger'
import { checkFFmpegEncoders } from '../initializers/checker'
+import { remove } from 'fs-extra'
function computeResolutionsToTranscode (videoFileHeight: number) {
const resolutionsEnabled: number[] = []
logger.error('Cannot generate image from video %s.', fromPath, { err })
try {
- await unlinkPromise(pendingImagePath)
+ await remove(pendingImagePath)
} catch (err) {
logger.debug('Cannot remove pending image path after generation error.', { err })
}
import 'multer'
import * as sharp from 'sharp'
-import { unlinkPromise } from './core-utils'
+import { remove } from 'fs-extra'
async function processImage (
physicalFile: { path: string },
.resize(newSize.width, newSize.height)
.toFile(destination)
- await unlinkPromise(physicalFile.path)
+ await remove(physicalFile.path)
}
// ---------------------------------------------------------------------------
import { CONFIG } from '../initializers'
import { ActorModel } from '../models/activitypub/actor'
import { ApplicationModel } from '../models/application/application'
-import { pseudoRandomBytesPromise, sha256, unlinkPromise } from './core-utils'
+import { pseudoRandomBytesPromise, sha256 } from './core-utils'
import { logger } from './logger'
import { join } from 'path'
import { Instance as ParseTorrent } from 'parse-torrent'
+import { remove } from 'fs-extra'
function deleteFileAsync (path: string) {
- unlinkPromise(path)
+ remove(path)
.catch(err => logger.error('Cannot delete the file %s asynchronously.', path, { err }))
}
import { logger } from './logger'
import { generateVideoTmpPath } from './utils'
import * as WebTorrent from 'webtorrent'
-import { createWriteStream } from 'fs-extra'
+import { createWriteStream, remove } from 'fs-extra'
import { CONFIG } from '../initializers'
import { join } from 'path'
-import { unlinkPromise } from './core-utils'
function downloadWebTorrentVideo (target: { magnetUri: string, torrentName: string }) {
const id = target.magnetUri || target.torrentName
if (err) return rej(err)
if (target.torrentName) {
- unlinkPromise(torrentId)
+ remove(torrentId)
.catch(err => logger.error('Cannot remove torrent %s in webtorrent download.', torrentId, { err }))
}
- unlinkPromise(join(CONFIG.STORAGE.VIDEOS_DIR, file.name))
+ remove(join(CONFIG.STORAGE.VIDEOS_DIR, file.name))
.catch(err => logger.error('Cannot remove torrent file %s in webtorrent download.', file.name, { err }))
res(path)
import * as passwordGenerator from 'password-generator'
import { UserRole } from '../../shared'
-import { mkdirpPromise, rimrafPromise } from '../helpers/core-utils'
import { logger } from '../helpers/logger'
import { createApplicationActor, createUserAccountAndChannel } from '../lib/user'
import { UserModel } from '../models/account/user'
import { applicationExist, clientsExist, usersExist } from './checker'
import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants'
import { sequelizeTypescript } from './database'
+import { remove, ensureDir } from 'fs-extra'
async function installApplication () {
try {
// Cache directories
for (const key of Object.keys(cacheDirectories)) {
const dir = cacheDirectories[key]
- tasks.push(rimrafPromise(dir))
+ tasks.push(remove(dir))
}
return Promise.all(tasks)
const cacheDirectories = Object.keys(CACHE)
.map(k => CACHE[k].DIRECTORY)
- const tasks: Promise<string>[] = []
+ const tasks: Promise<void>[] = []
for (const key of Object.keys(storage)) {
const dir = storage[key]
- tasks.push(mkdirpPromise(dir))
+ tasks.push(ensureDir(dir))
}
// Cache directories
for (const key of Object.keys(cacheDirectories)) {
const dir = cacheDirectories[key]
- tasks.push(mkdirpPromise(dir))
+ tasks.push(ensureDir(dir))
}
return Promise.all(tasks)
import * as Sequelize from 'sequelize'
import { join } from 'path'
-
-import { readdirPromise, renamePromise } from '../../helpers/core-utils'
import { CONFIG } from '../../initializers/constants'
import { getVideoFileResolution } from '../../helpers/ffmpeg-utils'
+import { readdir, rename } from 'fs-extra'
function up (utils: {
transaction: Sequelize.Transaction,
const torrentDir = CONFIG.STORAGE.TORRENTS_DIR
const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR
- return readdirPromise(videoFileDir)
+ return readdir(videoFileDir)
.then(videoFiles => {
const tasks: Promise<any>[] = []
for (const videoFile of videoFiles) {
.then(height => {
const oldTorrentName = uuid + '.torrent'
const newTorrentName = uuid + '-' + height + '.torrent'
- return renamePromise(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height)
+ return rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height)
})
.then(height => {
const newVideoFileName = uuid + '-' + height + '.' + ext
- return renamePromise(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height)
+ return rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height)
})
.then(height => {
const query = 'UPDATE "VideoFiles" SET "resolution" = ' + height +
import * as path from 'path'
-import { readdirPromise } from '../helpers/core-utils'
import { logger } from '../helpers/logger'
import { LAST_MIGRATION_VERSION } from './constants'
import { sequelizeTypescript } from './database'
+import { readdir } from 'fs-extra'
async function migrate () {
const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
// ---------------------------------------------------------------------------
async function getMigrationScripts () {
- const files = await readdirPromise(path.join(__dirname, 'migrations'))
+ const files = await readdir(path.join(__dirname, 'migrations'))
const filesToMigrate: {
version: string,
script: string
import * as AsyncLRU from 'async-lru'
-import { createWriteStream } from 'fs-extra'
-import { unlinkPromise } from '../../helpers/core-utils'
+import { createWriteStream, remove } from 'fs-extra'
import { logger } from '../../helpers/logger'
import { VideoModel } from '../../models/video/video'
import { fetchRemoteVideoStaticFile } from '../activitypub'
})
this.lru.on('evict', (obj: { key: string, value: string }) => {
- unlinkPromise(obj.value)
+ remove(obj.value)
.then(() => logger.debug('%s evicted from %s', obj.value, this.constructor.name))
})
}
import * as express from 'express'
import * as Bluebird from 'bluebird'
import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n'
-import { CONFIG, EMBED_SIZE, CUSTOM_HTML_TAG_COMMENTS, STATIC_PATHS } from '../initializers'
+import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, STATIC_PATHS } from '../initializers'
import { join } from 'path'
-import { escapeHTML, readFileBufferPromise } from '../helpers/core-utils'
+import { escapeHTML } from '../helpers/core-utils'
import { VideoModel } from '../models/video/video'
import * as validator from 'validator'
import { VideoPrivacy } from '../../shared/models/videos'
+import { readFile } from 'fs-extra'
export class ClientHtml {
const path = ClientHtml.getIndexPath(req, res, paramLang)
if (ClientHtml.htmlCache[path]) return ClientHtml.htmlCache[path]
- const buffer = await readFileBufferPromise(path)
+ const buffer = await readFile(path)
let html = buffer.toString()
import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
import { extname, join } from 'path'
import { VideoFileModel } from '../../../models/video/video-file'
-import { renamePromise, statPromise, unlinkPromise } from '../../../helpers/core-utils'
import { CONFIG, sequelizeTypescript } from '../../../initializers'
import { doRequestAndSaveToFile } from '../../../helpers/requests'
import { VideoState } from '../../../../shared'
import { VideoModel } from '../../../models/video/video'
import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'
import { getSecureTorrentName } from '../../../helpers/utils'
+import { rename, stat } from 'fs-extra'
type VideoImportYoutubeDLPayload = {
type: 'youtube-dl'
tempVideoPath = await downloader()
// Get information about this video
- const stats = await statPromise(tempVideoPath)
+ const stats = await stat(tempVideoPath)
const isAble = await videoImport.User.isAbleToUploadVideo({ size: stats.size })
if (isAble === false) {
throw new Error('The user video quota is exceeded with this video to import.')
// Move file
videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile))
- await renamePromise(tempVideoPath, videoDestFile)
+ await rename(tempVideoPath, videoDestFile)
tempVideoPath = null // This path is not used anymore
// Process thumbnail
import { SCHEDULER_INTERVALS_MS } from '../../initializers'
import { logger } from '../../helpers/logger'
import * as request from 'request'
-import { createWriteStream, writeFile } from 'fs-extra'
+import { createWriteStream, ensureDir, writeFile } from 'fs-extra'
import { join } from 'path'
-import { mkdirpPromise, root } from '../../helpers/core-utils'
+import { root } from '../../helpers/core-utils'
export class YoutubeDlUpdateScheduler extends AbstractScheduler {
const detailsPath = join(binDirectory, 'details')
const url = 'https://yt-dl.org/downloads/latest/youtube-dl'
- await mkdirpPromise(binDirectory)
+ await ensureDir(binDirectory)
return new Promise(res => {
request.get(url, { followRedirect: false }, (err, result) => {
import { join } from 'path'
import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { Avatar } from '../../../shared/models/avatars/avatar.model'
-import { unlinkPromise } from '../../helpers/core-utils'
import { CONFIG, STATIC_PATHS } from '../../initializers'
import { logger } from '../../helpers/logger'
+import { remove } from 'fs-extra'
@Table({
tableName: 'avatar'
removeAvatar () {
const avatarPath = join(CONFIG.STORAGE.AVATARS_DIR, this.filename)
- return unlinkPromise(avatarPath)
+ return remove(avatarPath)
}
}
import { CONFIG, STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers'
import { join } from 'path'
import { logger } from '../../helpers/logger'
-import { unlinkPromise } from '../../helpers/core-utils'
+import { remove } from 'fs-extra'
export enum ScopeNames {
WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE'
}
removeCaptionFile () {
- return unlinkPromise(CONFIG.STORAGE.CAPTIONS_DIR + this.getCaptionName())
+ return remove(CONFIG.STORAGE.CAPTIONS_DIR + this.getCaptionName())
}
}
import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos'
import { VideoFilter } from '../../../shared/models/videos/video-query.type'
-import {
- copyFilePromise,
- createTorrentPromise,
- peertubeTruncate,
- renamePromise,
- statPromise,
- unlinkPromise,
- writeFilePromise
-} from '../../helpers/core-utils'
+import { createTorrentPromise, peertubeTruncate } from '../../helpers/core-utils'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import { isBooleanValid } from '../../helpers/custom-validators/misc'
import {
import { ScheduleVideoUpdateModel } from './schedule-video-update'
import { VideoCaptionModel } from './video-caption'
import { VideoBlacklistModel } from './video-blacklist'
+import { copy, remove, rename, stat, writeFile } from 'fs-extra'
// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
const indexes: Sequelize.DefineIndexesOptions[] = [
const filePath = join(CONFIG.STORAGE.TORRENTS_DIR, this.getTorrentFileName(videoFile))
logger.info('Creating torrent %s.', filePath)
- await writeFilePromise(filePath, torrent)
+ await writeFile(filePath, torrent)
const parsedTorrent = parseTorrent(torrent)
videoFile.infoHash = parsedTorrent.infoHash
await transcode(transcodeOptions)
try {
- await unlinkPromise(videoInputPath)
+ await remove(videoInputPath)
// Important to do this before getVideoFilename() to take in account the new file extension
inputVideoFile.set('extname', newExtname)
const videoOutputPath = this.getVideoFilePath(inputVideoFile)
- await renamePromise(videoTranscodedPath, videoOutputPath)
- const stats = await statPromise(videoOutputPath)
+ await rename(videoTranscodedPath, videoOutputPath)
+ const stats = await stat(videoOutputPath)
const fps = await getVideoFileFPS(videoOutputPath)
inputVideoFile.set('size', stats.size)
await transcode(transcodeOptions)
- const stats = await statPromise(videoOutputPath)
+ const stats = await stat(videoOutputPath)
const fps = await getVideoFileFPS(videoOutputPath)
newVideoFile.set('size', stats.size)
async importVideoFile (inputFilePath: string) {
const { videoFileResolution } = await getVideoFileResolution(inputFilePath)
- const { size } = await statPromise(inputFilePath)
+ const { size } = await stat(inputFilePath)
const fps = await getVideoFileFPS(inputFilePath)
let updatedVideoFile = new VideoFileModel({
}
const outputPath = this.getVideoFilePath(updatedVideoFile)
- await copyFilePromise(inputFilePath, outputPath)
+ await copy(inputFilePath, outputPath)
await this.createTorrentAndSetInfoHash(updatedVideoFile)
removeThumbnail () {
const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName())
- return unlinkPromise(thumbnailPath)
+ return remove(thumbnailPath)
.catch(err => logger.warn('Cannot delete thumbnail %s.', thumbnailPath, { err }))
}
removePreview () {
const previewPath = join(CONFIG.STORAGE.PREVIEWS_DIR + this.getPreviewName())
- return unlinkPromise(previewPath)
+ return remove(previewPath)
.catch(err => logger.warn('Cannot delete preview %s.', previewPath, { err }))
}
removeFile (videoFile: VideoFileModel) {
const filePath = join(CONFIG.STORAGE.VIDEOS_DIR, this.getVideoFilename(videoFile))
- return unlinkPromise(filePath)
+ return remove(filePath)
.catch(err => logger.warn('Cannot delete file %s.', filePath, { err }))
}
removeTorrent (videoFile: VideoFileModel) {
const torrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, this.getTorrentFileName(videoFile))
- return unlinkPromise(torrentPath)
+ return remove(torrentPath)
.catch(err => logger.warn('Cannot delete torrent %s.', torrentPath, { err }))
}
setAccessTokensToServers,
uploadVideo
} from '../utils'
-import { join } from 'path'
import * as libxmljs from 'libxmljs'
import { addVideoCommentThread } from '../utils/videos/video-comments'
import { waitJobs } from '../utils/server/jobs'
import * as request from 'supertest'
-import { readFileBufferPromise } from '../../../helpers/core-utils'
type FeedType = 'videos' | 'video-comments'
import { isAbsolute, join } from 'path'
import * as request from 'supertest'
import * as WebTorrent from 'webtorrent'
-import { readFileBufferPromise } from '../../../helpers/core-utils'
+import { readFile } from 'fs-extra'
const expect = chai.expect
let webtorrent = new WebTorrent()
const body = res.body
- const data = await readFileBufferPromise(join(__dirname, '..', '..', 'fixtures', imageName + extension))
+ const data = await readFile(join(__dirname, '..', '..', 'fixtures', imageName + extension))
const minLength = body.length - ((20 * body.length) / 100)
const maxLength = body.length + ((20 * body.length) / 100)
/* tslint:disable:no-unused-expression */
import { expect } from 'chai'
-import { existsSync } from 'fs-extra'
+import { existsSync, readdir } from 'fs-extra'
import { join } from 'path'
import { Account } from '../../../../shared/models/actors'
-import { readdirPromise } from '../../../helpers/core-utils'
import { root } from '../index'
import { makeGetRequest } from '../requests/requests'
const directoryExists = existsSync(directoryPath)
expect(directoryExists).to.be.true
- const files = await readdirPromise(directoryPath)
+ const files = await readdir(directoryPath)
for (const file of files) {
expect(file).to.not.contain(actorUUID)
}
/* tslint:disable:no-unused-expression */
import { expect } from 'chai'
-import { existsSync, readFile } from 'fs-extra'
+import { existsSync, readdir, readFile } from 'fs-extra'
import * as parseTorrent from 'parse-torrent'
import { extname, join } from 'path'
import * as request from 'supertest'
import {
buildAbsoluteFixturePath,
- getMyUserInformation, immutableAssign,
+ getMyUserInformation,
+ immutableAssign,
makeGetRequest,
makePutBodyRequest,
makeUploadRequest,
testImage
} from '../'
import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
-import { readdirPromise } from '../../../helpers/core-utils'
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers'
import { dateIsValid, webtorrentAdd } from '../index'
const directoryExists = existsSync(directoryPath)
expect(directoryExists).to.be.true
- const files = await readdirPromise(directoryPath)
+ const files = await readdir(directoryPath)
for (const file of files) {
expect(file).to.not.contain(videoUUID)
}
import { join } from 'path'
import * as youtubeDL from 'youtube-dl'
import { VideoPrivacy } from '../../shared/models/videos'
-import { unlinkPromise } from '../helpers/core-utils'
import { doRequestAndSaveToFile } from '../helpers/requests'
import { CONSTRAINTS_FIELDS } from '../initializers'
import { getClient, getVideoCategories, login, searchVideo, uploadVideo } from '../tests/utils'
import { truncate } from 'lodash'
import * as prompt from 'prompt'
+import { remove } from 'fs-extra'
program
.option('-u, --url <url>', 'Server url')
}
}
- await unlinkPromise(videoPath)
- if (thumbnailfile) {
- await unlinkPromise(thumbnailfile)
- }
+ await remove(videoPath)
+ if (thumbnailfile) await remove(thumbnailfile)
console.log('Uploaded video "%s"!\n', videoAttributes.name)
}
import * as program from 'commander'
import { access, constants } from 'fs-extra'
import { isAbsolute } from 'path'
-import { promisify } from 'util'
import { getClient, login } from '../tests/utils'
import { uploadVideo } from '../tests/utils/index'
import { VideoPrivacy } from '../../shared/models/videos'
-const accessPromise = promisify(access)
-
program
.option('-u, --url <url>', 'Server url')
.option('-U, --username <username>', 'Username')
const res2 = await login(program[ 'url' ], client, user)
const accessToken = res2.body.access_token
- await accessPromise(program[ 'file' ], constants.F_OK)
+ await access(program[ 'file' ], constants.F_OK)
console.log('Uploading %s video...', program[ 'videoName' ])
dependencies:
"@types/node" "*"
+"@types/fs-extra@^5.0.4":
+ version "5.0.4"
+ resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.4.tgz#b971134d162cc0497d221adde3dbb67502225599"
+ dependencies:
+ "@types/node" "*"
+
"@types/geojson@^1.0.0":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-1.0.6.tgz#3e02972728c69248c2af08d60a48cbb8680fffdf"
jsonfile "^3.0.0"
universalify "^0.1.0"
+fs-extra@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.0.tgz#8cc3f47ce07ef7b3593a11b9fb245f7e34c041d6"
+ dependencies:
+ graceful-fs "^4.1.2"
+ jsonfile "^4.0.0"
+ universalify "^0.1.0"
+
fs-minipass@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
optionalDependencies:
graceful-fs "^4.1.6"
+jsonfile@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
+ optionalDependencies:
+ graceful-fs "^4.1.6"
+
jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
dependencies:
align-text "^0.1.1"
-rimraf@2, rimraf@2.x.x, rimraf@^2.2.8, rimraf@^2.4.2, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@~2.6.2:
+rimraf@2, rimraf@2.x.x, rimraf@^2.2.8, rimraf@^2.4.2, rimraf@^2.5.1, rimraf@^2.6.1, rimraf@~2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies: