Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vidéos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vidéos
Commits
26649b42
Unverified
Commit
26649b42
authored
6 years ago
by
Chocobozzz
Browse files
Options
Downloads
Patches
Plain Diff
Ensure video existence before duplicating it
parent
5e77a5de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/lib/activitypub/videos.ts
+7
-3
7 additions, 3 deletions
server/lib/activitypub/videos.ts
server/lib/schedulers/videos-redundancy-scheduler.ts
+21
-4
21 additions, 4 deletions
server/lib/schedulers/videos-redundancy-scheduler.ts
with
28 additions
and
7 deletions
server/lib/activitypub/videos.ts
+
7
−
3
View file @
26649b42
...
...
@@ -370,13 +370,15 @@ async function refreshVideoIfNeeded (options: {
try
{
const
{
response
,
videoObject
}
=
await
fetchRemoteVideo
(
video
.
url
)
if
(
response
.
statusCode
===
404
)
{
logger
.
info
(
'
Cannot refresh remote video %s: video does not exist anymore. Deleting it.
'
,
video
.
url
)
// Video does not exist anymore
await
video
.
destroy
()
return
undefined
}
if
(
videoObject
===
undefined
)
{
logger
.
warn
(
'
Cannot refresh remote video: invalid body.
'
)
logger
.
warn
(
'
Cannot refresh remote video
%s
: invalid body.
'
,
video
.
url
)
return
video
}
...
...
@@ -390,8 +392,10 @@ async function refreshVideoIfNeeded (options: {
channel
:
channelActor
.
VideoChannel
,
updateViews
:
options
.
refreshViews
}
await
retryTransactionWrapper
(
updateVideoFromAP
,
updateOptions
)
await
syncVideoExternalAttributes
(
video
,
videoObject
,
options
.
syncParam
)
const
videoUpdated
=
await
retryTransactionWrapper
(
updateVideoFromAP
,
updateOptions
)
await
syncVideoExternalAttributes
(
videoUpdated
,
videoObject
,
options
.
syncParam
)
return
videoUpdated
}
catch
(
err
)
{
logger
.
warn
(
'
Cannot refresh video.
'
,
{
err
})
return
video
...
...
This diff is collapsed.
Click to expand it.
server/lib/schedulers/videos-redundancy-scheduler.ts
+
21
−
4
View file @
26649b42
...
...
@@ -12,6 +12,7 @@ import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
import
{
VideoModel
}
from
'
../../models/video/video
'
import
{
getVideoCacheFileActivityPubUrl
}
from
'
../activitypub/url
'
import
{
removeVideoRedundancy
}
from
'
../redundancy
'
import
{
getOrCreateVideoAndAccountAndChannel
}
from
'
../activitypub
'
export
class
VideosRedundancyScheduler
extends
AbstractScheduler
{
...
...
@@ -109,16 +110,32 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
const
serverActor
=
await
getServerActor
()
for
(
const
file
of
filesToDuplicate
)
{
// We need more attributes and check if the video still exists
const
getVideoOptions
=
{
videoObject
:
file
.
Video
.
url
,
syncParam
:
{
likes
:
false
,
dislikes
:
false
,
shares
:
false
,
comments
:
false
,
thumbnail
:
false
,
refreshVideo
:
true
},
fetchType
:
'
only-video
'
as
'
only-video
'
}
const
{
video
}
=
await
getOrCreateVideoAndAccountAndChannel
(
getVideoOptions
)
const
existing
=
await
VideoRedundancyModel
.
loadLocalByFileId
(
file
.
id
)
if
(
existing
)
{
await
this
.
extendsExpirationOf
(
existing
,
redundancy
.
minLifetime
)
if
(
video
)
{
await
this
.
extendsExpirationOf
(
existing
,
redundancy
.
minLifetime
)
}
else
{
logger
.
info
(
'
Destroying existing redundancy %s, because the associated video does not exist anymore.
'
,
existing
.
url
)
await
existing
.
destroy
()
}
continue
}
// We need more attributes and check if the video still exists
const
video
=
await
VideoModel
.
loadAndPopulateAccountAndServerAndTags
(
file
.
Video
.
id
)
if
(
!
video
)
continue
if
(
!
video
)
{
logger
.
info
(
'
Video %s we want to duplicate does not existing anymore, skipping.
'
,
file
.
Video
.
url
)
continue
}
logger
.
info
(
'
Duplicating %s - %d in videos redundancy with "%s" strategy.
'
,
video
.
url
,
file
.
resolution
,
redundancy
.
strategy
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment