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
0bae6663
Verified
Commit
0bae6663
authored
Aug 26, 2021
by
Chocobozzz
Browse files
More logs for webtorrent download
parent
0dce48c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/helpers/webtorrent.ts
View file @
0bae6663
...
...
@@ -17,6 +17,7 @@ import { promisify2 } from './core-utils'
import
{
logger
}
from
'
./logger
'
import
{
generateVideoImportTmpPath
}
from
'
./utils
'
import
{
extractVideo
}
from
'
./video
'
import
{
pipeline
}
from
'
stream
'
const
createTorrentPromise
=
promisify2
<
string
,
any
,
any
>
(
createTorrent
)
...
...
@@ -49,6 +50,8 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
.
then
(()
=>
rej
(
new
Error
(
'
Cannot import torrent
'
+
torrentId
+
'
: there are multiple files in it
'
)))
}
logger
.
debug
(
'
Got torrent from webtorrent %s.
'
,
id
,
{
infoHash
:
torrent
.
infoHash
,
files
:
torrent
.
files
})
file
=
torrent
.
files
[
0
]
// FIXME: avoid creating another stream when https://github.com/webtorrent/webtorrent/issues/1517 is fixed
...
...
@@ -61,7 +64,11 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
.
catch
(
err
=>
logger
.
error
(
'
Cannot destroy webtorrent.
'
,
{
err
}))
})
file
.
createReadStream
().
pipe
(
writeStream
)
pipeline
(
file
.
createReadStream
(),
writeStream
,
err
=>
rej
(
err
)
)
})
torrent
.
on
(
'
error
'
,
err
=>
rej
(
err
))
...
...
server/lib/schedulers/videos-redundancy-scheduler.ts
View file @
0bae6663
...
...
@@ -329,14 +329,14 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
private
async
isTooHeavy
(
candidateToDuplicate
:
CandidateToDuplicate
)
{
const
maxSize
=
candidateToDuplicate
.
redundancy
.
size
const
{
totalUsed
:
u
sed
}
=
await
VideoRedundancyModel
.
getStats
(
candidateToDuplicate
.
redundancy
.
strategy
)
const
{
totalUsed
:
alreadyU
sed
}
=
await
VideoRedundancyModel
.
getStats
(
candidateToDuplicate
.
redundancy
.
strategy
)
const
videoSize
=
this
.
getTotalFileSizes
(
candidateToDuplicate
.
files
,
candidateToDuplicate
.
streamingPlaylists
)
const
total
=
u
sed
+
videoSize
const
willUse
=
alreadyU
sed
+
videoSize
logger
.
debug
(
'
Checking candidate size.
'
,
{
u
sed
,
videoSize
,
total
,
...
lTags
(
candidateToDuplicate
.
video
.
uuid
)
})
logger
.
debug
(
'
Checking candidate size.
'
,
{
maxSize
,
alreadyU
sed
,
videoSize
,
willUse
,
...
lTags
(
candidateToDuplicate
.
video
.
uuid
)
})
return
total
>
maxSize
return
willUse
>
maxSize
}
private
buildNewExpiration
(
expiresAfterMs
:
number
)
{
...
...
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