mirror of https://github.com/Chocobozzz/PeerTube
parent
14e2014acc
commit
f481c4f9f3
|
@ -21,7 +21,7 @@ import { VideoChannelModel } from '../../../models/video/video-channel'
|
||||||
import * as Bluebird from 'bluebird'
|
import * as Bluebird from 'bluebird'
|
||||||
import * as parseTorrent from 'parse-torrent'
|
import * as parseTorrent from 'parse-torrent'
|
||||||
import { getSecureTorrentName } from '../../../helpers/utils'
|
import { getSecureTorrentName } from '../../../helpers/utils'
|
||||||
import { readFile, rename } from 'fs-extra'
|
import { readFile, move } from 'fs-extra'
|
||||||
|
|
||||||
const auditLogger = auditLoggerFactory('video-imports')
|
const auditLogger = auditLoggerFactory('video-imports')
|
||||||
const videoImportsRouter = express.Router()
|
const videoImportsRouter = express.Router()
|
||||||
|
@ -71,7 +71,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
|
||||||
|
|
||||||
// Rename the torrent to a secured name
|
// Rename the torrent to a secured name
|
||||||
const newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName))
|
const newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName))
|
||||||
await rename(torrentfile.path, newTorrentPath)
|
await move(torrentfile.path, newTorrentPath)
|
||||||
torrentfile.path = newTorrentPath
|
torrentfile.path = newTorrentPath
|
||||||
|
|
||||||
const buf = await readFile(torrentfile.path)
|
const buf = await readFile(torrentfile.path)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { join } from 'path'
|
||||||
import { CONFIG } from '../initializers'
|
import { CONFIG } from '../initializers'
|
||||||
import { VideoCaptionModel } from '../models/video/video-caption'
|
import { VideoCaptionModel } from '../models/video/video-caption'
|
||||||
import * as srt2vtt from 'srt-to-vtt'
|
import * as srt2vtt from 'srt-to-vtt'
|
||||||
import { createReadStream, createWriteStream, remove, rename } from 'fs-extra'
|
import { createReadStream, createWriteStream, remove, move } from 'fs-extra'
|
||||||
|
|
||||||
async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) {
|
async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) {
|
||||||
const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
|
const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
|
||||||
|
@ -13,7 +13,7 @@ async function moveAndProcessCaptionFile (physicalFile: { filename: string, path
|
||||||
await convertSrtToVtt(physicalFile.path, destination)
|
await convertSrtToVtt(physicalFile.path, destination)
|
||||||
await remove(physicalFile.path)
|
await remove(physicalFile.path)
|
||||||
} else { // Just move the vtt file
|
} else { // Just move the vtt file
|
||||||
await rename(physicalFile.path, destination)
|
await move(physicalFile.path, destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is important in case if there is another attempt in the retry process
|
// This is important in case if there is another attempt in the retry process
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { federateVideoIfNeeded } from '../../activitypub'
|
||||||
import { VideoModel } from '../../../models/video/video'
|
import { VideoModel } from '../../../models/video/video'
|
||||||
import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'
|
import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'
|
||||||
import { getSecureTorrentName } from '../../../helpers/utils'
|
import { getSecureTorrentName } from '../../../helpers/utils'
|
||||||
import { remove, rename, stat } from 'fs-extra'
|
import { remove, move, stat } from 'fs-extra'
|
||||||
|
|
||||||
type VideoImportYoutubeDLPayload = {
|
type VideoImportYoutubeDLPayload = {
|
||||||
type: 'youtube-dl'
|
type: 'youtube-dl'
|
||||||
|
@ -139,7 +139,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
|
||||||
|
|
||||||
// Move file
|
// Move file
|
||||||
videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile))
|
videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile))
|
||||||
await rename(tempVideoPath, videoDestFile)
|
await move(tempVideoPath, videoDestFile)
|
||||||
tempVideoPath = null // This path is not used anymore
|
tempVideoPath = null // This path is not used anymore
|
||||||
|
|
||||||
// Process thumbnail
|
// Process thumbnail
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
|
||||||
import { VideoFileModel } from '../../models/video/video-file'
|
import { VideoFileModel } from '../../models/video/video-file'
|
||||||
import { downloadWebTorrentVideo } from '../../helpers/webtorrent'
|
import { downloadWebTorrentVideo } from '../../helpers/webtorrent'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { rename } from 'fs-extra'
|
import { move } from 'fs-extra'
|
||||||
import { getServerActor } from '../../helpers/utils'
|
import { getServerActor } from '../../helpers/utils'
|
||||||
import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
|
import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
|
||||||
import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
|
import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
|
||||||
|
@ -146,7 +146,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)
|
const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)
|
||||||
|
|
||||||
const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file))
|
const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file))
|
||||||
await rename(tmpPath, destPath)
|
await move(tmpPath, destPath)
|
||||||
|
|
||||||
const createdModel = await VideoRedundancyModel.create({
|
const createdModel = await VideoRedundancyModel.create({
|
||||||
expiresOn: this.buildNewExpiration(redundancy.minLifetime),
|
expiresOn: this.buildNewExpiration(redundancy.minLifetime),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { CONFIG } from '../initializers'
|
import { CONFIG } from '../initializers'
|
||||||
import { extname, join } from 'path'
|
import { extname, join } from 'path'
|
||||||
import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils'
|
import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils'
|
||||||
import { copy, remove, rename, stat } from 'fs-extra'
|
import { copy, remove, move, stat } from 'fs-extra'
|
||||||
import { logger } from '../helpers/logger'
|
import { logger } from '../helpers/logger'
|
||||||
import { VideoResolution } from '../../shared/models/videos'
|
import { VideoResolution } from '../../shared/models/videos'
|
||||||
import { VideoFileModel } from '../models/video/video-file'
|
import { VideoFileModel } from '../models/video/video-file'
|
||||||
|
@ -30,7 +30,7 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi
|
||||||
inputVideoFile.set('extname', newExtname)
|
inputVideoFile.set('extname', newExtname)
|
||||||
|
|
||||||
const videoOutputPath = video.getVideoFilePath(inputVideoFile)
|
const videoOutputPath = video.getVideoFilePath(inputVideoFile)
|
||||||
await rename(videoTranscodedPath, videoOutputPath)
|
await move(videoTranscodedPath, videoOutputPath)
|
||||||
const stats = await stat(videoOutputPath)
|
const stats = await stat(videoOutputPath)
|
||||||
const fps = await getVideoFileFPS(videoOutputPath)
|
const fps = await getVideoFileFPS(videoOutputPath)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue