aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-18 11:07:08 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-18 13:38:09 +0100
commitb3d5cb92b100406df98e5cd1f54eff9cd2078b1c (patch)
tree234c9b0b799424c1599af0dee27e84e4ad7240ff
parentd9a2a03196275065c28f4a0b7d4d7bc9992d77a1 (diff)
downloadPeerTube-b3d5cb92b100406df98e5cd1f54eff9cd2078b1c.tar.gz
PeerTube-b3d5cb92b100406df98e5cd1f54eff9cd2078b1c.tar.zst
PeerTube-b3d5cb92b100406df98e5cd1f54eff9cd2078b1c.zip
Add ability to update torrents cache in client
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html14
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts2
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts3
-rw-r--r--config/test.yaml2
-rw-r--r--server/controllers/api/config.ts3
-rw-r--r--server/lib/thumbnail.ts3
-rw-r--r--server/middlewares/validators/config.ts1
-rw-r--r--server/models/server/tracker.ts2
-rw-r--r--server/tests/api/check-params/config.ts3
-rw-r--r--server/tests/api/server/config.ts5
-rw-r--r--shared/extra-utils/server/config.ts3
-rw-r--r--shared/models/server/custom-config.model.ts4
12 files changed, 41 insertions, 4 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html
index 6018ff5e0..0ab80e5a9 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html
@@ -38,6 +38,20 @@
38 38
39 <div *ngIf="formErrors.cache.captions.size" class="form-error">{{ formErrors.cache.captions.size }}</div> 39 <div *ngIf="formErrors.cache.captions.size" class="form-error">{{ formErrors.cache.captions.size }}</div>
40 </div> 40 </div>
41
42 <div class="form-group" formGroupName="torrents">
43 <label i18n for="cacheTorrentsSize">Number of video torrents to keep in cache</label>
44
45 <div class="number-with-unit">
46 <input
47 type="number" min="0" id="cacheTorrentsSize" class="form-control"
48 formControlName="size" [ngClass]="{ 'input-error': formErrors['cache.torrents.size'] }"
49 >
50 <span i18n>{getCacheSize('torrents'), plural, =1 {cached torrent} other {cached torrents}}</span>
51 </div>
52
53 <div *ngIf="formErrors.cache.torrents.size" class="form-error">{{ formErrors.cache.torrents.size }}</div>
54 </div>
41 </ng-container> 55 </ng-container>
42 56
43 </div> 57 </div>
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts
index 934438a50..01ff022c5 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts
@@ -12,7 +12,7 @@ export class EditAdvancedConfigurationComponent {
12 @Input() form: FormGroup 12 @Input() form: FormGroup
13 @Input() formErrors: any 13 @Input() formErrors: any
14 14
15 getCacheSize (type: 'captions' | 'previews') { 15 getCacheSize (type: 'captions' | 'previews' | 'torrents') {
16 return this.form.value['cache'][type]['size'] 16 return this.form.value['cache'][type]['size']
17 } 17 }
18} 18}
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index 2c7a10937..4b35d65fc 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -105,6 +105,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
105 }, 105 },
106 captions: { 106 captions: {
107 size: CACHE_CAPTIONS_SIZE_VALIDATOR 107 size: CACHE_CAPTIONS_SIZE_VALIDATOR
108 },
109 torrents: {
110 size: CACHE_CAPTIONS_SIZE_VALIDATOR
108 } 111 }
109 }, 112 },
110 signup: { 113 signup: {
diff --git a/config/test.yaml b/config/test.yaml
index ae8011ba5..33c11afc3 100644
--- a/config/test.yaml
+++ b/config/test.yaml
@@ -61,6 +61,8 @@ cache:
61 size: 1 61 size: 1
62 captions: 62 captions:
63 size: 1 63 size: 1
64 torrents:
65 size: 1
64 66
65signup: 67signup:
66 enabled: true 68 enabled: true
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 5c242da04..fb108ca1c 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -395,6 +395,9 @@ function customConfig (): CustomConfig {
395 }, 395 },
396 captions: { 396 captions: {
397 size: CONFIG.CACHE.VIDEO_CAPTIONS.SIZE 397 size: CONFIG.CACHE.VIDEO_CAPTIONS.SIZE
398 },
399 torrents: {
400 size: CONFIG.CACHE.TORRENTS.SIZE
398 } 401 }
399 }, 402 },
400 signup: { 403 signup: {
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts
index 49317df28..e37aefc85 100644
--- a/server/lib/thumbnail.ts
+++ b/server/lib/thumbnail.ts
@@ -1,6 +1,5 @@
1import { copy } from 'fs-extra'
2import { join } from 'path' 1import { join } from 'path'
3import { logger } from '@server/helpers/logger' 2
4import { ThumbnailType } from '../../shared/models/videos/thumbnail.type' 3import { ThumbnailType } from '../../shared/models/videos/thumbnail.type'
5import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils' 4import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils'
6import { processImage } from '../helpers/image-utils' 5import { processImage } from '../helpers/image-utils'
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 71098ff99..a85883b19 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -25,6 +25,7 @@ const customConfigUpdateValidator = [
25 25
26 body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'), 26 body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'),
27 body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'), 27 body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'),
28 body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'),
28 29
29 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), 30 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),
30 body('signup.limit').isInt().withMessage('Should have a valid signup limit'), 31 body('signup.limit').isInt().withMessage('Should have a valid signup limit'),
diff --git a/server/models/server/tracker.ts b/server/models/server/tracker.ts
index d7c91faad..97520f92d 100644
--- a/server/models/server/tracker.ts
+++ b/server/models/server/tracker.ts
@@ -36,7 +36,7 @@ export class TrackerModel extends Model {
36 const query = { 36 const query = {
37 include: [ 37 include: [
38 { 38 {
39 attributes: [ 'id', 'trackerId' ], 39 attributes: [ 'id' ],
40 model: VideoModel.unscoped(), 40 model: VideoModel.unscoped(),
41 required: true, 41 required: true,
42 where: { id: videoId } 42 where: { id: videoId }
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index c7eb3189b..004aa65b3 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -65,6 +65,9 @@ describe('Test config API validators', function () {
65 }, 65 },
66 captions: { 66 captions: {
67 size: 3 67 size: 3
68 },
69 torrents: {
70 size: 4
68 } 71 }
69 }, 72 },
70 signup: { 73 signup: {
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index b2371614f..0b0f48d22 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -55,6 +55,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
55 55
56 expect(data.cache.previews.size).to.equal(1) 56 expect(data.cache.previews.size).to.equal(1)
57 expect(data.cache.captions.size).to.equal(1) 57 expect(data.cache.captions.size).to.equal(1)
58 expect(data.cache.torrents.size).to.equal(1)
58 59
59 expect(data.signup.enabled).to.be.true 60 expect(data.signup.enabled).to.be.true
60 expect(data.signup.limit).to.equal(4) 61 expect(data.signup.limit).to.equal(4)
@@ -144,6 +145,7 @@ function checkUpdatedConfig (data: CustomConfig) {
144 145
145 expect(data.cache.previews.size).to.equal(2) 146 expect(data.cache.previews.size).to.equal(2)
146 expect(data.cache.captions.size).to.equal(3) 147 expect(data.cache.captions.size).to.equal(3)
148 expect(data.cache.torrents.size).to.equal(4)
147 149
148 expect(data.signup.enabled).to.be.false 150 expect(data.signup.enabled).to.be.false
149 expect(data.signup.limit).to.equal(5) 151 expect(data.signup.limit).to.equal(5)
@@ -305,6 +307,9 @@ describe('Test config', function () {
305 }, 307 },
306 captions: { 308 captions: {
307 size: 3 309 size: 3
310 },
311 torrents: {
312 size: 4
308 } 313 }
309 }, 314 },
310 signup: { 315 signup: {
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts
index efe569243..026a5e61c 100644
--- a/shared/extra-utils/server/config.ts
+++ b/shared/extra-utils/server/config.ts
@@ -90,6 +90,9 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
90 }, 90 },
91 captions: { 91 captions: {
92 size: 3 92 size: 3
93 },
94 torrents: {
95 size: 4
93 } 96 }
94 }, 97 },
95 signup: { 98 signup: {
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts
index 93b2d3417..0bccd63e3 100644
--- a/shared/models/server/custom-config.model.ts
+++ b/shared/models/server/custom-config.model.ts
@@ -59,6 +59,10 @@ export interface CustomConfig {
59 captions: { 59 captions: {
60 size: number 60 size: number
61 } 61 }
62
63 torrents: {
64 size: number
65 }
62 } 66 }
63 67
64 signup: { 68 signup: {