mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Upsert cache file on create activity
This commit is contained in:
parent
278711b595
commit
b88a459664
3 changed files with 15 additions and 11 deletions
|
@ -22,6 +22,16 @@ function cacheFileActivityObjectToDBAttributes (cacheFileObject: CacheFileObject
|
|||
}
|
||||
}
|
||||
|
||||
async function createOrUpdateCacheFile (cacheFileObject: CacheFileObject, video: VideoModel, byActor: { id?: number }, t: Transaction) {
|
||||
const redundancyModel = await VideoRedundancyModel.loadByUrl(cacheFileObject.id, t)
|
||||
|
||||
if (!redundancyModel) {
|
||||
await createCacheFile(cacheFileObject, video, byActor, t)
|
||||
} else {
|
||||
await updateCacheFile(cacheFileObject, redundancyModel, video, byActor, t)
|
||||
}
|
||||
}
|
||||
|
||||
function createCacheFile (cacheFileObject: CacheFileObject, video: VideoModel, byActor: { id?: number }, t: Transaction) {
|
||||
const attributes = cacheFileActivityObjectToDBAttributes(cacheFileObject, video, byActor)
|
||||
|
||||
|
@ -48,6 +58,7 @@ function updateCacheFile (
|
|||
}
|
||||
|
||||
export {
|
||||
createOrUpdateCacheFile,
|
||||
createCacheFile,
|
||||
updateCacheFile,
|
||||
cacheFileActivityObjectToDBAttributes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue