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
8c5c1c23
Commit
8c5c1c23
authored
3 months ago
by
Adrien Béraud
Committed by
François-Simon Fauteux-Chapleau
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
TransferChannelHandler: run on io pool
GitLab:
#1110
Change-Id: I36e090fcb6c44b2483b1765786d64be108d93d21
parent
8eb66bf8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jamidht/transfer_channel_handler.cpp
+43
-36
43 additions, 36 deletions
src/jamidht/transfer_channel_handler.cpp
with
43 additions
and
36 deletions
src/jamidht/transfer_channel_handler.cpp
+
43
−
36
View file @
8c5c1c23
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include
"jamidht/transfer_channel_handler.h"
#include
"jamidht/transfer_channel_handler.h"
#include
<opendht/thread_pool.h>
#include
<charconv>
#include
<charconv>
#include
"fileutils.h"
#include
"fileutils.h"
...
@@ -118,7 +119,7 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
...
@@ -118,7 +119,7 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
sha3Sum
=
keyVal
[
1
];
sha3Sum
=
keyVal
[
1
];
}
else
if
(
keyVal
[
0
]
==
"modified"
)
{
}
else
if
(
keyVal
[
0
]
==
"modified"
)
{
try
{
try
{
lastModified
=
jami
::
to_int
<
uint64_t
>
(
keyVal
[
1
]);
lastModified
=
to_int
<
uint64_t
>
(
keyVal
[
1
]);
}
catch
(
const
std
::
exception
&
e
)
{
}
catch
(
const
std
::
exception
&
e
)
{
JAMI_WARNING
(
"TransferChannel: Unable to parse modified date: {}: {}"
,
JAMI_WARNING
(
"TransferChannel: Unable to parse modified date: {}: {}"
,
keyVal
[
1
],
keyVal
[
1
],
...
@@ -130,6 +131,8 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
...
@@ -130,6 +131,8 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
// Check if profile
// Check if profile
if
(
idstr
==
"profile.vcf"
)
{
if
(
idstr
==
"profile.vcf"
)
{
dht
::
ThreadPool
::
io
().
run
([
wacc
=
acc
->
weak
(),
path
=
idPath_
/
"profile.vcf"
,
channel
,
idstr
,
lastModified
,
sha3Sum
]
{
if
(
auto
acc
=
wacc
.
lock
())
{
if
(
!
channel
->
isInitiator
())
{
if
(
!
channel
->
isInitiator
())
{
// Only accept newest profiles
// Only accept newest profiles
if
(
lastModified
==
0
if
(
lastModified
==
0
...
@@ -139,15 +142,16 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
...
@@ -139,15 +142,16 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
channel
->
shutdown
();
channel
->
shutdown
();
}
else
{
}
else
{
// If it's a profile from sync
// If it's a profile from sync
auto
path
=
idPath_
/
"profile.vcf"
;
acc
->
dataTransfer
()
->
transferFile
(
channel
,
idstr
,
""
,
path
.
string
());
acc
->
dataTransfer
()
->
transferFile
(
channel
,
idstr
,
""
,
path
.
string
());
}
}
}
});
return
;
return
;
}
}
auto
splitted_id
=
split_string
(
idstr
,
'/'
);
auto
splitted_id
=
split_string
(
idstr
,
'/'
);
if
(
splitted_id
.
size
()
<
3
)
{
if
(
splitted_id
.
size
()
<
3
)
{
JAMI_ERR
()
<<
"Unsupported ID detected
"
<<
name
;
JAMI_ERR
OR
(
"Unsupported ID detected
{}"
,
name
)
;
channel
->
shutdown
();
channel
->
shutdown
();
return
;
return
;
}
}
...
@@ -161,9 +165,10 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
...
@@ -161,9 +165,10 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
return
;
return
;
// Profile for a member in the conversation
// Profile for a member in the conversation
dht
::
ThreadPool
::
io
().
run
([
wacc
=
acc
->
weak
(),
profilePath
=
idPath_
/
"profile.vcf"
,
channel
,
conversationId
,
fileId
,
isContactProfile
,
idstr
,
start
,
end
,
sha3Sum
]
{
if
(
auto
acc
=
wacc
.
lock
())
{
if
(
fileId
==
fmt
::
format
(
"{}.vcf"
,
acc
->
getUsername
()))
{
if
(
fileId
==
fmt
::
format
(
"{}.vcf"
,
acc
->
getUsername
()))
{
auto
path
=
idPath_
/
"profile.vcf"
;
acc
->
dataTransfer
()
->
transferFile
(
channel
,
fileId
,
""
,
profilePath
.
string
());
acc
->
dataTransfer
()
->
transferFile
(
channel
,
fileId
,
""
,
path
.
string
());
return
;
return
;
}
else
if
(
isContactProfile
&&
fileId
.
find
(
".vcf"
)
!=
std
::
string
::
npos
)
{
}
else
if
(
isContactProfile
&&
fileId
.
find
(
".vcf"
)
!=
std
::
string
::
npos
)
{
auto
path
=
acc
->
dataTransfer
()
->
profilePath
(
fileId
.
substr
(
0
,
fileId
.
size
()
-
4
));
auto
path
=
acc
->
dataTransfer
()
->
profilePath
(
fileId
.
substr
(
0
,
fileId
.
size
()
-
4
));
...
@@ -175,7 +180,7 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
...
@@ -175,7 +180,7 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
}
}
// Check if it's a file in a conversation
// Check if it's a file in a conversation
auto
dt
=
acc
->
dataTransfer
(
conversationId
);
auto
dt
=
acc
->
dataTransfer
(
conversationId
);
sep
=
fileId
.
find
(
'_'
);
auto
sep
=
fileId
.
find
(
'_'
);
if
(
!
dt
or
sep
==
std
::
string
::
npos
)
{
if
(
!
dt
or
sep
==
std
::
string
::
npos
)
{
channel
->
shutdown
();
channel
->
shutdown
();
return
;
return
;
...
@@ -184,5 +189,7 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
...
@@ -184,5 +189,7 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
auto
path
=
dt
->
path
(
fileId
);
auto
path
=
dt
->
path
(
fileId
);
dt
->
transferFile
(
channel
,
fileId
,
interactionId
,
path
.
string
(),
start
,
end
);
dt
->
transferFile
(
channel
,
fileId
,
interactionId
,
path
.
string
(),
start
,
end
);
}
}
});
}
}
// namespace jami
}
// namespace jami
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