aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/redundancy
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-28 10:56:13 +0200
committerChocobozzz <me@florianbigard.com>2018-09-28 10:56:13 +0200
commit5ce1208a0a57d566b5b1fd57ec291a7d053ebaf0 (patch)
tree5d2484446fa2e277a4ec15fd36a1c6a55c12e519 /server/models/redundancy
parent07524e229fa88a0d01af9d52ce124760f8ca5fa4 (diff)
downloadPeerTube-5ce1208a0a57d566b5b1fd57ec291a7d053ebaf0.tar.gz
PeerTube-5ce1208a0a57d566b5b1fd57ec291a7d053ebaf0.tar.zst
PeerTube-5ce1208a0a57d566b5b1fd57ec291a7d053ebaf0.zip
Improve prune script
Diffstat (limited to 'server/models/redundancy')
-rw-r--r--server/models/redundancy/video-redundancy.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index e67164802..791ba3137 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -146,6 +146,38 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
146 return VideoRedundancyModel.findOne(query) 146 return VideoRedundancyModel.findOne(query)
147 } 147 }
148 148
149 static async isLocalByVideoUUIDExists (uuid: string) {
150 const actor = await getServerActor()
151
152 const query = {
153 raw: true,
154 attributes: [ 'id' ],
155 where: {
156 actorId: actor.id
157 },
158 include: [
159 {
160 attributes: [ ],
161 model: VideoFileModel,
162 required: true,
163 include: [
164 {
165 attributes: [ ],
166 model: VideoModel,
167 required: true,
168 where: {
169 uuid
170 }
171 }
172 ]
173 }
174 ]
175 }
176
177 return VideoRedundancyModel.findOne(query)
178 .then(r => !!r)
179 }
180
149 static async getVideoSample (p: Bluebird<VideoModel[]>) { 181 static async getVideoSample (p: Bluebird<VideoModel[]>) {
150 const rows = await p 182 const rows = await p
151 const ids = rows.map(r => r.id) 183 const ids = rows.map(r => r.id)