-import { registerTSPaths } from '../server/helpers/register-ts-paths'
-registerTSPaths()
-
-import * as prompt from 'prompt'
-import { join, basename } from 'path'
+import { map } from 'bluebird'
+import { readdir, remove, stat } from 'fs-extra'
+import { uniq, values } from 'lodash'
+import { basename, join } from 'path'
+import { get, start } from 'prompt'
+import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
+import { VideoFileModel } from '@server/models/video/video-file'
+import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
+import { ThumbnailType } from '@shared/models'
+import { getUUIDFromFilename } from '../server/helpers/utils'
import { CONFIG } from '../server/initializers/config'
-import { VideoModel } from '../server/models/video/video'
import { initDatabaseModels } from '../server/initializers/database'
-import { readdir, remove, stat } from 'fs-extra'
+import { ActorImageModel } from '../server/models/actor/actor-image'
import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
-import * as Bluebird from 'bluebird'
-import { getUUIDFromFilename } from '../server/helpers/utils'
import { ThumbnailModel } from '../server/models/video/thumbnail'
-import { ActorImageModel } from '../server/models/actor/actor-image'
-import { uniq, values } from 'lodash'
-import { ThumbnailType } from '@shared/models'
-import { VideoFileModel } from '@server/models/video/video-file'
+import { VideoModel } from '../server/models/video/video'
run()
.then(() => process.exit(0))
toDelete = toDelete.concat(
await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()),
+
+ await pruneDirectory(HLS_STREAMING_PLAYLIST_DIRECTORY, doesHLSPlaylistExist()),
+
await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()),
await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist),
const files = await readdir(directory)
const toDelete: string[] = []
- await Bluebird.map(files, async file => {
+ await map(files, async file => {
const filePath = join(directory, file)
if (await existFun(filePath) !== true) {
return (filePath: string) => VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath))
}
+function doesHLSPlaylistExist () {
+ return (hlsPath: string) => VideoStreamingPlaylistModel.doesOwnedHLSPlaylistExist(basename(hlsPath))
+}
+
function doesTorrentFileExist () {
return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath))
}
const isPlaylist = (await stat(filePath)).isDirectory()
if (isPlaylist) {
+ // Don't delete HLS directory
+ if (filePath === HLS_REDUNDANCY_DIRECTORY) return true
+
const uuid = getUUIDFromFilename(filePath)
const video = await VideoModel.loadWithFiles(uuid)
if (!video) return false
async function askConfirmation () {
return new Promise((res, rej) => {
- prompt.start()
+ start()
const schema = {
properties: {
confirm: {
}
}
}
- prompt.get(schema, function (err, result) {
+ get(schema, function (err, result) {
if (err) return rej(err)
return res(result.confirm?.match(/y/) !== null)