Also prune storyboards and actor images
This commit is contained in:
parent
2b189131fa
commit
585050821a
|
@ -43,7 +43,13 @@ describe('Test prune storage CLI', function () {
|
|||
await server.videos.quickUpload({ name: 'video 1', privacy: VideoPrivacy.PUBLIC })
|
||||
await server.videos.quickUpload({ name: 'video 2', privacy: VideoPrivacy.PUBLIC })
|
||||
|
||||
await server.videos.quickUpload({ name: 'video 3', privacy: VideoPrivacy.PRIVATE })
|
||||
const { uuid } = await server.videos.quickUpload({ name: 'video 3', privacy: VideoPrivacy.PRIVATE })
|
||||
|
||||
await server.captions.add({
|
||||
language: 'ar',
|
||||
videoId: uuid,
|
||||
fixture: 'subtitle-good1.vtt'
|
||||
})
|
||||
|
||||
await server.users.updateMyAvatar({ fixture: 'avatar.png' })
|
||||
|
||||
|
@ -137,6 +143,12 @@ describe('Test prune storage CLI', function () {
|
|||
const originalVideoFilesCount = await server.servers.countFiles(join('original-video-files'))
|
||||
expect(originalVideoFilesCount).to.equal(3)
|
||||
|
||||
const storyboardsCount = await server.servers.countFiles(join('storyboards'))
|
||||
expect(storyboardsCount).to.equal(3)
|
||||
|
||||
const captionsCount = await server.servers.countFiles(join('captions'))
|
||||
expect(captionsCount).to.equal(1)
|
||||
|
||||
const userExportFilesCount = await server.servers.countFiles(join('tmp-persistent'))
|
||||
expect(userExportFilesCount).to.equal(1)
|
||||
}
|
||||
|
@ -175,32 +187,8 @@ describe('Test prune storage CLI', function () {
|
|||
badNames['torrents'] = [ n1, n2 ]
|
||||
}
|
||||
|
||||
{
|
||||
const base = servers[0].servers.buildDirectory('thumbnails')
|
||||
|
||||
const n1 = buildUUID() + '.jpg'
|
||||
const n2 = buildUUID() + '.jpg'
|
||||
|
||||
await createFile(join(base, n1))
|
||||
await createFile(join(base, n2))
|
||||
|
||||
badNames['thumbnails'] = [ n1, n2 ]
|
||||
}
|
||||
|
||||
{
|
||||
const base = servers[0].servers.buildDirectory('previews')
|
||||
|
||||
const n1 = buildUUID() + '.jpg'
|
||||
const n2 = buildUUID() + '.jpg'
|
||||
|
||||
await createFile(join(base, n1))
|
||||
await createFile(join(base, n2))
|
||||
|
||||
badNames['previews'] = [ n1, n2 ]
|
||||
}
|
||||
|
||||
{
|
||||
const base = servers[0].servers.buildDirectory('avatars')
|
||||
for (const name of [ 'thumbnails', 'previews', 'avatars', 'storyboards' ]) {
|
||||
const base = servers[0].servers.buildDirectory(name)
|
||||
|
||||
const n1 = buildUUID() + '.png'
|
||||
const n2 = buildUUID() + '.jpg'
|
||||
|
@ -208,7 +196,7 @@ describe('Test prune storage CLI', function () {
|
|||
await createFile(join(base, n1))
|
||||
await createFile(join(base, n2))
|
||||
|
||||
badNames['avatars'] = [ n1, n2 ]
|
||||
badNames[name] = [ n1, n2 ]
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -231,6 +219,18 @@ describe('Test prune storage CLI', function () {
|
|||
badNames['original-video-files'] = [ n1 ]
|
||||
}
|
||||
|
||||
{
|
||||
const base = servers[0].servers.buildDirectory('captions')
|
||||
|
||||
const n1 = buildUUID() + '.vtt'
|
||||
const n2 = buildUUID() + '.srt'
|
||||
|
||||
await createFile(join(base, n1))
|
||||
await createFile(join(base, n2))
|
||||
|
||||
badNames['captions'] = [ n1, n2 ]
|
||||
}
|
||||
|
||||
{
|
||||
const base = servers[0].servers.buildDirectory('tmp-persistent')
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export class AvatarPermanentFileCache extends AbstractPermanentFileCache<MActorI
|
|||
}
|
||||
|
||||
protected loadModel (filename: string) {
|
||||
return ActorImageModel.loadByName(filename)
|
||||
return ActorImageModel.loadByFilename(filename)
|
||||
}
|
||||
|
||||
protected getImageSize (image: MActorImage): { width: number, height: number } {
|
||||
|
|
|
@ -100,7 +100,7 @@ export class ActorImageModel extends SequelizeModel<ActorImageModel> {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static loadByName (filename: string) {
|
||||
static loadByFilename (filename: string) {
|
||||
const query = {
|
||||
where: {
|
||||
filename
|
||||
|
|
|
@ -3,6 +3,8 @@ import { FileStorage, ThumbnailType, ThumbnailType_Type } from '@peertube/peertu
|
|||
import { DIRECTORIES, USER_EXPORT_FILE_PREFIX } from '@server/initializers/constants.js'
|
||||
import { listKeysOfPrefix, removeObjectByFullKey } from '@server/lib/object-storage/object-storage-helpers.js'
|
||||
import { UserExportModel } from '@server/models/user/user-export.js'
|
||||
import { StoryboardModel } from '@server/models/video/storyboard.js'
|
||||
import { VideoCaptionModel } from '@server/models/video/video-caption.js'
|
||||
import { VideoFileModel } from '@server/models/video/video-file.js'
|
||||
import { VideoSourceModel } from '@server/models/video/video-source.js'
|
||||
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js'
|
||||
|
@ -170,6 +172,10 @@ class FSPruner {
|
|||
await this.findFilesToDelete(CONFIG.STORAGE.PREVIEWS_DIR, this.doesThumbnailExistFactory(true, ThumbnailType.PREVIEW))
|
||||
await this.findFilesToDelete(CONFIG.STORAGE.THUMBNAILS_DIR, this.doesThumbnailExistFactory(false, ThumbnailType.MINIATURE))
|
||||
|
||||
await this.findFilesToDelete(CONFIG.STORAGE.CAPTIONS_DIR, this.doesCaptionExistFactory())
|
||||
|
||||
await this.findFilesToDelete(CONFIG.STORAGE.STORYBOARDS_DIR, this.doesStoryboardExistFactory())
|
||||
|
||||
await this.findFilesToDelete(CONFIG.STORAGE.ACTOR_IMAGES_DIR, this.doesActorImageExistFactory())
|
||||
|
||||
await this.findFilesToDelete(CONFIG.STORAGE.TMP_PERSISTENT_DIR, this.doesUserExportExistFactory())
|
||||
|
@ -256,12 +262,28 @@ class FSPruner {
|
|||
|
||||
private doesActorImageExistFactory () {
|
||||
return async (filePath: string) => {
|
||||
const image = await ActorImageModel.loadByName(basename(filePath))
|
||||
const image = await ActorImageModel.loadByFilename(basename(filePath))
|
||||
|
||||
return !!image
|
||||
}
|
||||
}
|
||||
|
||||
private doesStoryboardExistFactory () {
|
||||
return async (filePath: string) => {
|
||||
const storyboard = await StoryboardModel.loadByFilename(basename(filePath))
|
||||
|
||||
return !!storyboard
|
||||
}
|
||||
}
|
||||
|
||||
private doesCaptionExistFactory () {
|
||||
return async (filePath: string) => {
|
||||
const caption = await VideoCaptionModel.loadWithVideoByFilename(basename(filePath))
|
||||
|
||||
return !!caption
|
||||
}
|
||||
}
|
||||
|
||||
private doesRedundancyExistFactory () {
|
||||
return async (filePath: string) => {
|
||||
const isPlaylist = (await stat(filePath)).isDirectory()
|
||||
|
|
Loading…
Reference in New Issue