ActivityPub-federated video streaming platform using P2P directly in your web browser
Use move instead rename
Chocobozzzf481c4f9f31e
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.tsindex 099ab7b8d6..98366cd82c 100644--- a/server/controllers/api/videos/import.ts+++ b/server/controllers/api/videos/import.ts@@ -21,7 +21,7 @@ import { VideoChannelModel } from '../../../models/video/video-channel'import * as Bluebird from 'bluebird'import * as parseTorrent from 'parse-torrent'import { getSecureTorrentName } from '../../../helpers/utils'-import { readFile, rename } from 'fs-extra'+import { readFile, move } from 'fs-extra'const auditLogger = auditLoggerFactory('video-imports')const videoImportsRouter = express.Router()@@ -71,7 +71,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to// Rename the torrent to a secured nameconst newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName))- await rename(torrentfile.path, newTorrentPath)+ await move(torrentfile.path, newTorrentPath)torrentfile.path = newTorrentPathconst buf = await readFile(torrentfile.path)diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.tsindex 660dce65c3..1aafbf8056 100644--- a/server/helpers/captions-utils.ts+++ b/server/helpers/captions-utils.ts@@ -2,7 +2,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, remove, rename } from 'fs-extra'+import { createReadStream, createWriteStream, remove, move } from 'fs-extra'async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) {const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR@@ -13,7 +13,7 @@ async function moveAndProcessCaptionFile (physicalFile: { filename: string, pathawait convertSrtToVtt(physicalFile.path, destination)await remove(physicalFile.path)} 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 processdiff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.tsindex 51a0b5faf5..63aacff98f 100644--- a/server/lib/job-queue/handlers/video-import.ts+++ b/server/lib/job-queue/handlers/video-import.ts@@ -14,7 +14,7 @@ import { federateVideoIfNeeded } from '../../activitypub'import { VideoModel } from '../../../models/video/video'import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'import { getSecureTorrentName } from '../../../helpers/utils'-import { remove, rename, stat } from 'fs-extra'+import { remove, move, stat } from 'fs-extra'type VideoImportYoutubeDLPayload = {type: 'youtube-dl'@@ -139,7 +139,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide// Move filevideoDestFile = 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// Process thumbnaildiff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.tsindex 2a99a665d1..15e094d39d 100644--- a/server/lib/schedulers/videos-redundancy-scheduler.ts+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts@@ -6,7 +6,7 @@ import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'import { VideoFileModel } from '../../models/video/video-file'import { downloadWebTorrentVideo } from '../../helpers/webtorrent'import { join } from 'path'-import { rename } from 'fs-extra'+import { move } from 'fs-extra'import { getServerActor } from '../../helpers/utils'import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'@@ -146,7 +146,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file))- await rename(tmpPath, destPath)+ await move(tmpPath, destPath)const createdModel = await VideoRedundancyModel.create({expiresOn: this.buildNewExpiration(redundancy.minLifetime),diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.tsindex a78de61e56..4460f46e41 100644--- a/server/lib/video-transcoding.ts+++ b/server/lib/video-transcoding.ts@@ -1,7 +1,7 @@import { CONFIG } from '../initializers'import { extname, join } from 'path'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 { VideoResolution } from '../../shared/models/videos'import { VideoFileModel } from '../models/video/video-file'@@ -30,7 +30,7 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFiinputVideoFile.set('extname', newExtname)const videoOutputPath = video.getVideoFilePath(inputVideoFile)- await rename(videoTranscodedPath, videoOutputPath)+ await move(videoTranscodedPath, videoOutputPath)const stats = await stat(videoOutputPath)const fps = await getVideoFileFPS(videoOutputPath)