Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
8b3a5ebb
Commit
8b3a5ebb
authored
1 year ago
by
Kateryna Kostiuk
Browse files
Options
Downloads
Patches
Plain Diff
conversation: fix download file transfer
Change-Id: I4037895ce57758541e61a89b7efeaccd71e79c5a
parent
3bbac872
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jamidht/conversation.cpp
+19
-8
19 additions, 8 deletions
src/jamidht/conversation.cpp
with
19 additions
and
8 deletions
src/jamidht/conversation.cpp
+
19
−
8
View file @
8b3a5ebb
...
@@ -1574,19 +1574,30 @@ Conversation::downloadFile(const std::string& interactionId,
...
@@ -1574,19 +1574,30 @@ Conversation::downloadFile(const std::string& interactionId,
std
::
size_t
end
)
std
::
size_t
end
)
{
{
auto
commit
=
getCommit
(
interactionId
);
auto
commit
=
getCommit
(
interactionId
);
if
(
commit
==
std
::
nullopt
||
commit
->
find
(
"type"
)
==
commit
->
end
()
if
(
commit
==
std
::
nullopt
||
commit
->
at
(
"type"
)
!=
"application/data-transfer+json"
)
{
||
commit
->
find
(
"sha3sum"
)
==
commit
->
end
()
||
commit
->
find
(
"tid"
)
==
commit
->
end
()
JAMI_ERROR
(
"Commit doesn't exists or is not a file transfer"
);
||
commit
->
at
(
"type"
)
!=
"application/data-transfer+json"
)
{
return
false
;
JAMI_ERR
()
<<
"Cannot download file without linked interaction "
<<
fileId
;
}
auto
tid
=
commit
->
find
(
"tid"
);
auto
sha3sum
=
commit
->
find
(
"sha3sum"
);
auto
size_str
=
commit
->
find
(
"totalSize"
);
if
(
tid
==
commit
->
end
()
||
sha3sum
==
commit
->
end
()
||
size_str
==
commit
->
end
())
{
JAMI_ERROR
(
"Invalid file transfer commit (missing tid, size or sha3)"
);
return
false
;
}
auto
totalSize
=
to_int
<
ssize_t
>
(
size_str
->
second
,
(
ssize_t
)
-
1
);
if
(
totalSize
<
0
)
{
JAMI_ERROR
(
"Invalid file size {}"
,
totalSize
);
return
false
;
return
false
;
}
}
auto
sha3sum
=
commit
->
at
(
"sha3sum"
);
auto
size_str
=
commit
->
at
(
"totalSize"
);
auto
totalSize
=
to_int
<
size_t
>
(
size_str
);
// Be sure to not lock conversation
// Be sure to not lock conversation
dht
::
ThreadPool
().
io
().
run
(
dht
::
ThreadPool
().
io
().
run
(
[
w
=
weak
(),
deviceId
,
fileId
,
interactionId
,
sha3sum
,
path
,
totalSize
,
start
,
end
]
{
[
w
=
weak
(),
deviceId
,
fileId
,
interactionId
,
sha3sum
=
sha3sum
->
second
,
path
,
totalSize
,
start
,
end
]
{
if
(
auto
shared
=
w
.
lock
())
{
if
(
auto
shared
=
w
.
lock
())
{
auto
acc
=
shared
->
pimpl_
->
account_
.
lock
();
auto
acc
=
shared
->
pimpl_
->
account_
.
lock
();
if
(
!
acc
)
if
(
!
acc
)
...
...
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