import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { JobQueue } from '../../../lib/job-queue'
+import { removeRedundancyOf } from '../../../lib/redundancy'
const serverFollowsRouter = express.Router()
serverFollowsRouter.get('/following',
server.redundancyAllowed = false
await server.save({ transaction: t })
+ // Async, could be long
+ removeRedundancyOf(server.id)
+ .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, err))
+
await follow.destroy({ transaction: t })
})
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy'
import { ServerModel } from '../../../models/server/server'
+import { removeRedundancyOf } from '../../../lib/redundancy'
+import { logger } from '../../../helpers/logger'
const serverRedundancyRouter = express.Router()
await server.save()
+ // Async, could be long
+ removeRedundancyOf(server.id)
+ .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, err))
+
return res.sendStatus(204)
}
killallServers, makeGetRequest,
root,
ServerInfo,
- setAccessTokensToServers,
+ setAccessTokensToServers, unfollow,
uploadVideo,
viewVideo,
wait
const found = parsed.urlList.find(url => url === `${ws}-${file.resolution.id}.mp4`)
expect(found, `Webseed ${ws} not found in ${file.magnetUri} on server ${server.url}`).to.not.be.undefined
}
+
+ expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length)
}
async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) {
]
for (const server of servers) {
- {
- const res = await getVideo(server.url, videoUUID)
+ const res = await getVideo(server.url, videoUUID)
- const video: VideoDetails = res.body
+ const video: VideoDetails = res.body
- for (const file of video.files) {
- checkMagnetWebseeds(file, webseeds, server)
-
- // Only servers 1 and 2 have the video
- if (server.serverNumber !== 3) {
- await makeGetRequest({
- url: server.url,
- statusCodeExpected: 200,
- path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`,
- contentType: null
- })
- }
+ for (const file of video.files) {
+ checkMagnetWebseeds(file, webseeds, server)
+
+ // Only servers 1 and 2 have the video
+ if (server.serverNumber !== 3) {
+ await makeGetRequest({
+ url: server.url,
+ statusCodeExpected: 200,
+ path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`,
+ contentType: null
+ })
}
}
}
expect(server2.following.hostRedundancyAllowed).to.be.true
}
+async function disableRedundancyOnServer1 () {
+ await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, false)
+
+ const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt')
+ const follows: ActorFollow[] = res.body.data
+ const server2 = follows.find(f => f.following.host === 'localhost:9002')
+ const server3 = follows.find(f => f.following.host === 'localhost:9003')
+
+ expect(server3).to.not.be.undefined
+ expect(server3.following.hostRedundancyAllowed).to.be.false
+
+ expect(server2).to.not.be.undefined
+ expect(server2.following.hostRedundancyAllowed).to.be.false
+}
+
async function cleanServers () {
killallServers(servers)
}
await checkStatsWith2Webseed(strategy)
})
+ it('Should undo redundancy on server 1 and remove duplicated videos', async function () {
+ this.timeout(40000)
+
+ await disableRedundancyOnServer1()
+
+ await waitJobs(servers)
+ await wait(5000)
+
+ await check1WebSeed(strategy)
+ })
+
after(function () {
return cleanServers()
})
await checkStatsWith2Webseed(strategy)
})
+ it('Should unfollow on server 1 and remove duplicated videos', async function () {
+ this.timeout(40000)
+
+ await unfollow(servers[0].url, servers[0].accessToken, servers[1])
+
+ await waitJobs(servers)
+ await wait(5000)
+
+ await check1WebSeed(strategy)
+ })
+
after(function () {
return cleanServers()
})