mirror of https://github.com/Chocobozzz/PeerTube
Add ability to update torrents cache in client
parent
d9a2a03196
commit
b3d5cb92b1
|
@ -38,6 +38,20 @@
|
|||
|
||||
<div *ngIf="formErrors.cache.captions.size" class="form-error">{{ formErrors.cache.captions.size }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" formGroupName="torrents">
|
||||
<label i18n for="cacheTorrentsSize">Number of video torrents to keep in cache</label>
|
||||
|
||||
<div class="number-with-unit">
|
||||
<input
|
||||
type="number" min="0" id="cacheTorrentsSize" class="form-control"
|
||||
formControlName="size" [ngClass]="{ 'input-error': formErrors['cache.torrents.size'] }"
|
||||
>
|
||||
<span i18n>{getCacheSize('torrents'), plural, =1 {cached torrent} other {cached torrents}}</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="formErrors.cache.torrents.size" class="form-error">{{ formErrors.cache.torrents.size }}</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@ export class EditAdvancedConfigurationComponent {
|
|||
@Input() form: FormGroup
|
||||
@Input() formErrors: any
|
||||
|
||||
getCacheSize (type: 'captions' | 'previews') {
|
||||
getCacheSize (type: 'captions' | 'previews' | 'torrents') {
|
||||
return this.form.value['cache'][type]['size']
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,6 +105,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
|||
},
|
||||
captions: {
|
||||
size: CACHE_CAPTIONS_SIZE_VALIDATOR
|
||||
},
|
||||
torrents: {
|
||||
size: CACHE_CAPTIONS_SIZE_VALIDATOR
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
|
|
|
@ -61,6 +61,8 @@ cache:
|
|||
size: 1
|
||||
captions:
|
||||
size: 1
|
||||
torrents:
|
||||
size: 1
|
||||
|
||||
signup:
|
||||
enabled: true
|
||||
|
|
|
@ -395,6 +395,9 @@ function customConfig (): CustomConfig {
|
|||
},
|
||||
captions: {
|
||||
size: CONFIG.CACHE.VIDEO_CAPTIONS.SIZE
|
||||
},
|
||||
torrents: {
|
||||
size: CONFIG.CACHE.TORRENTS.SIZE
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { copy } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
|
||||
import { ThumbnailType } from '../../shared/models/videos/thumbnail.type'
|
||||
import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils'
|
||||
import { processImage } from '../helpers/image-utils'
|
||||
|
|
|
@ -25,6 +25,7 @@ const customConfigUpdateValidator = [
|
|||
|
||||
body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'),
|
||||
body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'),
|
||||
body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'),
|
||||
|
||||
body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),
|
||||
body('signup.limit').isInt().withMessage('Should have a valid signup limit'),
|
||||
|
|
|
@ -36,7 +36,7 @@ export class TrackerModel extends Model {
|
|||
const query = {
|
||||
include: [
|
||||
{
|
||||
attributes: [ 'id', 'trackerId' ],
|
||||
attributes: [ 'id' ],
|
||||
model: VideoModel.unscoped(),
|
||||
required: true,
|
||||
where: { id: videoId }
|
||||
|
|
|
@ -65,6 +65,9 @@ describe('Test config API validators', function () {
|
|||
},
|
||||
captions: {
|
||||
size: 3
|
||||
},
|
||||
torrents: {
|
||||
size: 4
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
|
|
|
@ -55,6 +55,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
|
|||
|
||||
expect(data.cache.previews.size).to.equal(1)
|
||||
expect(data.cache.captions.size).to.equal(1)
|
||||
expect(data.cache.torrents.size).to.equal(1)
|
||||
|
||||
expect(data.signup.enabled).to.be.true
|
||||
expect(data.signup.limit).to.equal(4)
|
||||
|
@ -144,6 +145,7 @@ function checkUpdatedConfig (data: CustomConfig) {
|
|||
|
||||
expect(data.cache.previews.size).to.equal(2)
|
||||
expect(data.cache.captions.size).to.equal(3)
|
||||
expect(data.cache.torrents.size).to.equal(4)
|
||||
|
||||
expect(data.signup.enabled).to.be.false
|
||||
expect(data.signup.limit).to.equal(5)
|
||||
|
@ -305,6 +307,9 @@ describe('Test config', function () {
|
|||
},
|
||||
captions: {
|
||||
size: 3
|
||||
},
|
||||
torrents: {
|
||||
size: 4
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
|
|
|
@ -90,6 +90,9 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
|
|||
},
|
||||
captions: {
|
||||
size: 3
|
||||
},
|
||||
torrents: {
|
||||
size: 4
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
|
|
|
@ -59,6 +59,10 @@ export interface CustomConfig {
|
|||
captions: {
|
||||
size: number
|
||||
}
|
||||
|
||||
torrents: {
|
||||
size: number
|
||||
}
|
||||
}
|
||||
|
||||
signup: {
|
||||
|
|
Loading…
Reference in New Issue