diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-11 15:12:38 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-12-11 15:12:38 +0100 |
commit | f481c4f9f31e897a08e818f388fecdee07f57142 (patch) | |
tree | 2a47adb746d7bfc5046fa7e610408223c921db83 | |
parent | 14e2014acc1362cfbb770c051a7254b156cd8efb (diff) | |
download | PeerTube-f481c4f9f31e897a08e818f388fecdee07f57142.tar.gz PeerTube-f481c4f9f31e897a08e818f388fecdee07f57142.tar.zst PeerTube-f481c4f9f31e897a08e818f388fecdee07f57142.zip |
Use move instead rename
To avoid EXDEV errors
-rw-r--r-- | server/controllers/api/videos/import.ts | 4 | ||||
-rw-r--r-- | server/helpers/captions-utils.ts | 4 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 4 | ||||
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 4 | ||||
-rw-r--r-- | server/lib/video-transcoding.ts | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 099ab7b8d..98366cd82 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' | |||
21 | import * as Bluebird from 'bluebird' | 21 | import * as Bluebird from 'bluebird' |
22 | import * as parseTorrent from 'parse-torrent' | 22 | import * as parseTorrent from 'parse-torrent' |
23 | import { getSecureTorrentName } from '../../../helpers/utils' | 23 | import { getSecureTorrentName } from '../../../helpers/utils' |
24 | import { readFile, rename } from 'fs-extra' | 24 | import { readFile, move } from 'fs-extra' |
25 | 25 | ||
26 | const auditLogger = auditLoggerFactory('video-imports') | 26 | const auditLogger = auditLoggerFactory('video-imports') |
27 | const videoImportsRouter = express.Router() | 27 | const videoImportsRouter = express.Router() |
@@ -71,7 +71,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to | |||
71 | 71 | ||
72 | // Rename the torrent to a secured name | 72 | // Rename the torrent to a secured name |
73 | const newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName)) | 73 | const newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName)) |
74 | await rename(torrentfile.path, newTorrentPath) | 74 | await move(torrentfile.path, newTorrentPath) |
75 | torrentfile.path = newTorrentPath | 75 | torrentfile.path = newTorrentPath |
76 | 76 | ||
77 | const buf = await readFile(torrentfile.path) | 77 | const buf = await readFile(torrentfile.path) |
diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts index 660dce65c..1aafbf805 100644 --- a/server/helpers/captions-utils.ts +++ b/server/helpers/captions-utils.ts | |||
@@ -2,7 +2,7 @@ import { join } from 'path' | |||
2 | import { CONFIG } from '../initializers' | 2 | import { CONFIG } from '../initializers' |
3 | import { VideoCaptionModel } from '../models/video/video-caption' | 3 | import { VideoCaptionModel } from '../models/video/video-caption' |
4 | import * as srt2vtt from 'srt-to-vtt' | 4 | import * as srt2vtt from 'srt-to-vtt' |
5 | import { createReadStream, createWriteStream, remove, rename } from 'fs-extra' | 5 | import { createReadStream, createWriteStream, remove, move } from 'fs-extra' |
6 | 6 | ||
7 | async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) { | 7 | async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) { |
8 | const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR | 8 | const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR |
@@ -13,7 +13,7 @@ async function moveAndProcessCaptionFile (physicalFile: { filename: string, path | |||
13 | await convertSrtToVtt(physicalFile.path, destination) | 13 | await convertSrtToVtt(physicalFile.path, destination) |
14 | await remove(physicalFile.path) | 14 | await remove(physicalFile.path) |
15 | } else { // Just move the vtt file | 15 | } else { // Just move the vtt file |
16 | await rename(physicalFile.path, destination) | 16 | await move(physicalFile.path, destination) |
17 | } | 17 | } |
18 | 18 | ||
19 | // This is important in case if there is another attempt in the retry process | 19 | // This is important in case if there is another attempt in the retry process |
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 51a0b5faf..63aacff98 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' | |||
14 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
16 | import { getSecureTorrentName } from '../../../helpers/utils' | 16 | import { getSecureTorrentName } from '../../../helpers/utils' |
17 | import { remove, rename, stat } from 'fs-extra' | 17 | import { remove, move, stat } from 'fs-extra' |
18 | 18 | ||
19 | type VideoImportYoutubeDLPayload = { | 19 | type VideoImportYoutubeDLPayload = { |
20 | type: 'youtube-dl' | 20 | type: 'youtube-dl' |
@@ -139,7 +139,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide | |||
139 | 139 | ||
140 | // Move file | 140 | // Move file |
141 | videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile)) | 141 | videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile)) |
142 | await rename(tempVideoPath, videoDestFile) | 142 | await move(tempVideoPath, videoDestFile) |
143 | tempVideoPath = null // This path is not used anymore | 143 | tempVideoPath = null // This path is not used anymore |
144 | 144 | ||
145 | // Process thumbnail | 145 | // Process thumbnail |
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 2a99a665d..15e094d39 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' | |||
6 | import { VideoFileModel } from '../../models/video/video-file' | 6 | import { VideoFileModel } from '../../models/video/video-file' |
7 | import { downloadWebTorrentVideo } from '../../helpers/webtorrent' | 7 | import { downloadWebTorrentVideo } from '../../helpers/webtorrent' |
8 | import { join } from 'path' | 8 | import { join } from 'path' |
9 | import { rename } from 'fs-extra' | 9 | import { move } from 'fs-extra' |
10 | import { getServerActor } from '../../helpers/utils' | 10 | import { getServerActor } from '../../helpers/utils' |
11 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' | 11 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' |
12 | import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' | 12 | import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' |
@@ -146,7 +146,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
146 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) | 146 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) |
147 | 147 | ||
148 | const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file)) | 148 | const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file)) |
149 | await rename(tmpPath, destPath) | 149 | await move(tmpPath, destPath) |
150 | 150 | ||
151 | const createdModel = await VideoRedundancyModel.create({ | 151 | const createdModel = await VideoRedundancyModel.create({ |
152 | expiresOn: this.buildNewExpiration(redundancy.minLifetime), | 152 | expiresOn: this.buildNewExpiration(redundancy.minLifetime), |
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index a78de61e5..4460f46e4 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { CONFIG } from '../initializers' | 1 | import { CONFIG } from '../initializers' |
2 | import { extname, join } from 'path' | 2 | import { extname, join } from 'path' |
3 | import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' | 3 | import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' |
4 | import { copy, remove, rename, stat } from 'fs-extra' | 4 | import { copy, remove, move, stat } from 'fs-extra' |
5 | import { logger } from '../helpers/logger' | 5 | import { logger } from '../helpers/logger' |
6 | import { VideoResolution } from '../../shared/models/videos' | 6 | import { VideoResolution } from '../../shared/models/videos' |
7 | import { VideoFileModel } from '../models/video/video-file' | 7 | import { VideoFileModel } from '../models/video/video-file' |
@@ -30,7 +30,7 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi | |||
30 | inputVideoFile.set('extname', newExtname) | 30 | inputVideoFile.set('extname', newExtname) |
31 | 31 | ||
32 | const videoOutputPath = video.getVideoFilePath(inputVideoFile) | 32 | const videoOutputPath = video.getVideoFilePath(inputVideoFile) |
33 | await rename(videoTranscodedPath, videoOutputPath) | 33 | await move(videoTranscodedPath, videoOutputPath) |
34 | const stats = await stat(videoOutputPath) | 34 | const stats = await stat(videoOutputPath) |
35 | const fps = await getVideoFileFPS(videoOutputPath) | 35 | const fps = await getVideoFileFPS(videoOutputPath) |
36 | 36 | ||