Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
9db2330e
Verified
Commit
9db2330e
authored
Oct 08, 2021
by
Chocobozzz
Browse files
Fix notification on create transcoding job
parent
731a32e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
server/lib/video-state.ts
View file @
9db2330e
...
@@ -70,13 +70,13 @@ async function moveToPublishedState (video: MVideoFullLight, isNewVideo: boolean
...
@@ -70,13 +70,13 @@ async function moveToPublishedState (video: MVideoFullLight, isNewVideo: boolean
logger
.
info
(
'
Publishing video %s.
'
,
video
.
uuid
,
{
tags
:
[
video
.
uuid
]
})
logger
.
info
(
'
Publishing video %s.
'
,
video
.
uuid
,
{
tags
:
[
video
.
uuid
]
})
const
previousState
=
video
.
state
const
previousState
=
video
.
state
await
video
.
setNewState
(
VideoState
.
PUBLISHED
,
transaction
)
await
video
.
setNewState
(
VideoState
.
PUBLISHED
,
isNewVideo
,
transaction
)
// If the video was not published, we consider it is a new one for other instances
// If the video was not published, we consider it is a new one for other instances
// Live videos are always federated, so it's not a new video
// Live videos are always federated, so it's not a new video
await
federateVideoIfNeeded
(
video
,
isNewVideo
,
transaction
)
await
federateVideoIfNeeded
(
video
,
isNewVideo
,
transaction
)
Notifier
.
Instance
.
notifyOnNewVideoIfNeeded
(
video
)
if
(
isNewVideo
)
Notifier
.
Instance
.
notifyOnNewVideoIfNeeded
(
video
)
if
(
previousState
===
VideoState
.
TO_TRANSCODE
)
{
if
(
previousState
===
VideoState
.
TO_TRANSCODE
)
{
Notifier
.
Instance
.
notifyOnVideoPublishedAfterTranscoding
(
video
)
Notifier
.
Instance
.
notifyOnVideoPublishedAfterTranscoding
(
video
)
...
@@ -90,7 +90,7 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b
...
@@ -90,7 +90,7 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b
// We want to wait all transcoding jobs before moving the video on an external storage
// We want to wait all transcoding jobs before moving the video on an external storage
if
(
pendingTranscode
!==
0
)
return
if
(
pendingTranscode
!==
0
)
return
await
video
.
setNewState
(
VideoState
.
TO_MOVE_TO_EXTERNAL_STORAGE
,
transaction
)
await
video
.
setNewState
(
VideoState
.
TO_MOVE_TO_EXTERNAL_STORAGE
,
isNewVideo
,
transaction
)
logger
.
info
(
'
Creating external storage move job for video %s.
'
,
video
.
uuid
,
{
tags
:
[
video
.
uuid
]
})
logger
.
info
(
'
Creating external storage move job for video %s.
'
,
video
.
uuid
,
{
tags
:
[
video
.
uuid
]
})
...
...
server/models/video/video.ts
View file @
9db2330e
...
@@ -1766,12 +1766,12 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
...
@@ -1766,12 +1766,12 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
this
.
privacy
===
VideoPrivacy
.
INTERNAL
this
.
privacy
===
VideoPrivacy
.
INTERNAL
}
}
async
setNewState
(
newState
:
VideoState
,
transaction
:
Transaction
)
{
async
setNewState
(
newState
:
VideoState
,
isNewVideo
:
boolean
,
transaction
:
Transaction
)
{
if
(
this
.
state
===
newState
)
throw
new
Error
(
'
Cannot use same state
'
+
newState
)
if
(
this
.
state
===
newState
)
throw
new
Error
(
'
Cannot use same state
'
+
newState
)
this
.
state
=
newState
this
.
state
=
newState
if
(
this
.
state
===
VideoState
.
PUBLISHED
)
{
if
(
this
.
state
===
VideoState
.
PUBLISHED
&&
isNewVideo
)
{
this
.
publishedAt
=
new
Date
()
this
.
publishedAt
=
new
Date
()
}
}
...
...
server/tests/cli/create-transcoding-job.ts
View file @
9db2330e
...
@@ -33,9 +33,10 @@ async function checkFilesInObjectStorage (files: VideoFile[], type: 'webtorrent'
...
@@ -33,9 +33,10 @@ async function checkFilesInObjectStorage (files: VideoFile[], type: 'webtorrent'
function
runTests
(
objectStorage
:
boolean
)
{
function
runTests
(
objectStorage
:
boolean
)
{
let
servers
:
PeerTubeServer
[]
=
[]
let
servers
:
PeerTubeServer
[]
=
[]
const
videosUUID
:
string
[]
=
[]
const
videosUUID
:
string
[]
=
[]
const
publishedAt
:
string
[]
=
[]
before
(
async
function
()
{
before
(
async
function
()
{
this
.
timeout
(
6
0000
)
this
.
timeout
(
12
0000
)
const
config
=
objectStorage
const
config
=
objectStorage
?
ObjectStorageCommand
.
getDefaultConfig
()
?
ObjectStorageCommand
.
getDefaultConfig
()
...
@@ -54,6 +55,11 @@ function runTests (objectStorage: boolean) {
...
@@ -54,6 +55,11 @@ function runTests (objectStorage: boolean) {
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
const
{
uuid
,
shortUUID
}
=
await
servers
[
0
].
videos
.
upload
({
attributes
:
{
name
:
'
video
'
+
i
}
})
const
{
uuid
,
shortUUID
}
=
await
servers
[
0
].
videos
.
upload
({
attributes
:
{
name
:
'
video
'
+
i
}
})
await
waitJobs
(
servers
)
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
uuid
})
publishedAt
.
push
(
video
.
publishedAt
as
string
)
if
(
i
>
2
)
{
if
(
i
>
2
)
{
videosUUID
.
push
(
uuid
)
videosUUID
.
push
(
uuid
)
}
else
{
}
else
{
...
@@ -225,6 +231,14 @@ function runTests (objectStorage: boolean) {
...
@@ -225,6 +231,14 @@ function runTests (objectStorage: boolean) {
}
}
})
})
it
(
'
Should not have updated published at attributes
'
,
async
function
()
{
for
(
const
id
of
videosUUID
)
{
const
video
=
await
servers
[
0
].
videos
.
get
({
id
})
expect
(
publishedAt
.
some
(
p
=>
video
.
publishedAt
===
p
)).
to
.
be
.
true
}
})
after
(
async
function
()
{
after
(
async
function
()
{
await
cleanupTests
(
servers
)
await
cleanupTests
(
servers
)
})
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment