diff options
Diffstat (limited to 'server/lib/activitypub/cache-file.ts')
-rw-r--r-- | server/lib/activitypub/cache-file.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/lib/activitypub/cache-file.ts b/server/lib/activitypub/cache-file.ts index 5286d8e6d..f6f068b45 100644 --- a/server/lib/activitypub/cache-file.ts +++ b/server/lib/activitypub/cache-file.ts | |||
@@ -22,6 +22,16 @@ function cacheFileActivityObjectToDBAttributes (cacheFileObject: CacheFileObject | |||
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | async function createOrUpdateCacheFile (cacheFileObject: CacheFileObject, video: VideoModel, byActor: { id?: number }, t: Transaction) { | ||
26 | const redundancyModel = await VideoRedundancyModel.loadByUrl(cacheFileObject.id, t) | ||
27 | |||
28 | if (!redundancyModel) { | ||
29 | await createCacheFile(cacheFileObject, video, byActor, t) | ||
30 | } else { | ||
31 | await updateCacheFile(cacheFileObject, redundancyModel, video, byActor, t) | ||
32 | } | ||
33 | } | ||
34 | |||
25 | function createCacheFile (cacheFileObject: CacheFileObject, video: VideoModel, byActor: { id?: number }, t: Transaction) { | 35 | function createCacheFile (cacheFileObject: CacheFileObject, video: VideoModel, byActor: { id?: number }, t: Transaction) { |
26 | const attributes = cacheFileActivityObjectToDBAttributes(cacheFileObject, video, byActor) | 36 | const attributes = cacheFileActivityObjectToDBAttributes(cacheFileObject, video, byActor) |
27 | 37 | ||
@@ -48,6 +58,7 @@ function updateCacheFile ( | |||
48 | } | 58 | } |
49 | 59 | ||
50 | export { | 60 | export { |
61 | createOrUpdateCacheFile, | ||
51 | createCacheFile, | 62 | createCacheFile, |
52 | updateCacheFile, | 63 | updateCacheFile, |
53 | cacheFileActivityObjectToDBAttributes | 64 | cacheFileActivityObjectToDBAttributes |