aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 10:28:57 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:22 +0200
commit9cc8d43e37a61709e7275c2a799bdf976dd940ca (patch)
tree0d8d8967d39d6ecebbc480be53c528e696ce30e7 /server/lib
parent2fb5b3a55aeebcc77f4b3a0c029bbf0738ef0063 (diff)
downloadPeerTube-9cc8d43e37a61709e7275c2a799bdf976dd940ca.tar.gz
PeerTube-9cc8d43e37a61709e7275c2a799bdf976dd940ca.tar.zst
PeerTube-9cc8d43e37a61709e7275c2a799bdf976dd940ca.zip
Add migrations
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/process/process-undo.ts5
-rw-r--r--server/lib/thumbnail.ts22
2 files changed, 15 insertions, 12 deletions
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts
index ed0177a67..2d48848fe 100644
--- a/server/lib/activitypub/process/process-undo.ts
+++ b/server/lib/activitypub/process/process-undo.ts
@@ -108,7 +108,10 @@ async function processUndoCacheFile (byActor: ActorModel, activity: ActivityUndo
108 108
109 return sequelizeTypescript.transaction(async t => { 109 return sequelizeTypescript.transaction(async t => {
110 const cacheFile = await VideoRedundancyModel.loadByUrl(cacheFileObject.id) 110 const cacheFile = await VideoRedundancyModel.loadByUrl(cacheFileObject.id)
111 if (!cacheFile) throw new Error('Unknown video cache ' + cacheFileObject.id) 111 if (!cacheFile) {
112 logger.debug('Cannot undo unknown video cache %s.', cacheFileObject.id)
113 return
114 }
112 115
113 if (cacheFile.actorId !== byActor.id) throw new Error('Cannot delete redundancy ' + cacheFile.url + ' of another actor.') 116 if (cacheFile.actorId !== byActor.id) throw new Error('Cannot delete redundancy ' + cacheFile.url + ' of another actor.')
114 117
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts
index 4ba521b97..950b14c3b 100644
--- a/server/lib/thumbnail.ts
+++ b/server/lib/thumbnail.ts
@@ -20,19 +20,19 @@ function createPlaylistMiniatureFromExisting (inputPath: string, playlist: Video
20 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail }) 20 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail })
21} 21}
22 22
23function createPlaylistMiniatureFromUrl (url: string, playlist: VideoPlaylistModel, size?: ImageSize) { 23function createPlaylistMiniatureFromUrl (fileUrl: string, playlist: VideoPlaylistModel, size?: ImageSize) {
24 const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size) 24 const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size)
25 const type = ThumbnailType.MINIATURE 25 const type = ThumbnailType.MINIATURE
26 26
27 const thumbnailCreator = () => downloadImage(url, basePath, filename, { width, height }) 27 const thumbnailCreator = () => downloadImage(fileUrl, basePath, filename, { width, height })
28 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, url }) 28 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
29} 29}
30 30
31function createVideoMiniatureFromUrl (url: string, video: VideoModel, type: ThumbnailType, size?: ImageSize) { 31function createVideoMiniatureFromUrl (fileUrl: string, video: VideoModel, type: ThumbnailType, size?: ImageSize) {
32 const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) 32 const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
33 const thumbnailCreator = () => downloadImage(url, basePath, filename, { width, height }) 33 const thumbnailCreator = () => downloadImage(fileUrl, basePath, filename, { width, height })
34 34
35 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, url }) 35 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
36} 36}
37 37
38function createVideoMiniatureFromExisting (inputPath: string, video: VideoModel, type: ThumbnailType, size?: ImageSize) { 38function createVideoMiniatureFromExisting (inputPath: string, video: VideoModel, type: ThumbnailType, size?: ImageSize) {
@@ -51,7 +51,7 @@ function generateVideoMiniature (video: VideoModel, videoFile: VideoFileModel, t
51 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail }) 51 return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail })
52} 52}
53 53
54function createPlaceholderThumbnail (url: string, video: VideoModel, type: ThumbnailType, size: ImageSize) { 54function createPlaceholderThumbnail (fileUrl: string, video: VideoModel, type: ThumbnailType, size: ImageSize) {
55 const { filename, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) 55 const { filename, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
56 56
57 const thumbnail = existingThumbnail ? existingThumbnail : new ThumbnailModel() 57 const thumbnail = existingThumbnail ? existingThumbnail : new ThumbnailModel()
@@ -60,7 +60,7 @@ function createPlaceholderThumbnail (url: string, video: VideoModel, type: Thumb
60 thumbnail.height = height 60 thumbnail.height = height
61 thumbnail.width = width 61 thumbnail.width = width
62 thumbnail.type = type 62 thumbnail.type = type
63 thumbnail.url = url 63 thumbnail.fileUrl = fileUrl
64 64
65 return thumbnail 65 return thumbnail
66} 66}
@@ -132,10 +132,10 @@ async function createThumbnailFromFunction (parameters: {
132 height: number, 132 height: number,
133 width: number, 133 width: number,
134 type: ThumbnailType, 134 type: ThumbnailType,
135 url?: string, 135 fileUrl?: string,
136 existingThumbnail?: ThumbnailModel 136 existingThumbnail?: ThumbnailModel
137}) { 137}) {
138 const { thumbnailCreator, filename, width, height, type, existingThumbnail, url = null } = parameters 138 const { thumbnailCreator, filename, width, height, type, existingThumbnail, fileUrl = null } = parameters
139 139
140 const thumbnail = existingThumbnail ? existingThumbnail : new ThumbnailModel() 140 const thumbnail = existingThumbnail ? existingThumbnail : new ThumbnailModel()
141 141
@@ -143,7 +143,7 @@ async function createThumbnailFromFunction (parameters: {
143 thumbnail.height = height 143 thumbnail.height = height
144 thumbnail.width = width 144 thumbnail.width = width
145 thumbnail.type = type 145 thumbnail.type = type
146 thumbnail.url = url 146 thumbnail.fileUrl = fileUrl
147 147
148 await thumbnailCreator() 148 await thumbnailCreator()
149 149