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
488d90bd
Commit
488d90bd
authored
1 year ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
TransferManager: move profile to destination
Change-Id: Ie4ef56a2d8bfb2a062ad7f0b43f0921843e4af4f
parent
b69db815
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/data_transfer.cpp
+20
-5
20 additions, 5 deletions
src/data_transfer.cpp
with
20 additions
and
5 deletions
src/data_transfer.cpp
+
20
−
5
View file @
488d90bd
...
...
@@ -247,6 +247,7 @@ public:
waitingPath_
=
conversationDataPath_
/
"waiting"
;
}
profilesPath_
=
fileutils
::
get_data_dir
()
/
accountId_
/
"profiles"
;
accountProfilePath_
=
fileutils
::
get_data_dir
()
/
accountId
/
"profile.vcf"
;
loadWaiting
();
}
...
...
@@ -285,6 +286,7 @@ public:
std
::
string
to_
{};
std
::
filesystem
::
path
waitingPath_
{};
std
::
filesystem
::
path
profilesPath_
{};
std
::
filesystem
::
path
accountProfilePath_
{};
std
::
filesystem
::
path
conversationDataPath_
{};
std
::
mutex
mapMutex_
{};
...
...
@@ -510,7 +512,7 @@ TransferManager::onIncomingProfile(const std::shared_ptr<dhtnet::ChannelSocket>&
:
fileId
.
substr
(
0
,
fileId
.
size
()
-
4
/*.vcf*/
);
std
::
lock_guard
<
std
::
mutex
>
lk
(
pimpl_
->
mapMutex_
);
auto
idx
=
std
::
pair
<
std
::
string
,
std
::
string
>
{
deviceId
,
uri
}
;
auto
idx
=
std
::
make_pair
(
deviceId
,
uri
)
;
// Check if not already an incoming file for this id and that we are waiting this file
auto
itV
=
pimpl_
->
vcards_
.
find
(
idx
);
if
(
itV
!=
pimpl_
->
vcards_
.
end
())
{
...
...
@@ -536,24 +538,37 @@ TransferManager::onIncomingProfile(const std::shared_ptr<dhtnet::ChannelSocket>&
accountId
=
pimpl_
->
accountId_
,
cert
=
std
::
move
(
cert
),
path
=
info
.
path
](
uint32_t
code
)
{
// schedule destroy transfer as not needed
dht
::
ThreadPool
().
computation
().
run
([
w
,
uri
=
std
::
move
(
uri
),
deviceId
=
std
::
move
(
deviceId
),
accountId
=
std
::
move
(
accountId
),
cert
=
std
::
move
(
cert
),
path
=
std
::
move
(
path
),
code
]
{
if
(
auto
sthis_
=
w
.
lock
())
{
auto
&
pimpl
=
sthis_
->
pimpl_
;
std
::
lock_guard
<
std
::
mutex
>
lk
{
pimpl
->
mapMutex_
};
auto
destPath
=
sthis_
->
profilePath
(
uri
);
{
// Move profile to destination path
std
::
lock_guard
lock
(
dhtnet
::
fileutils
::
getFileLock
(
destPath
));
std
::
filesystem
::
rename
(
path
,
destPath
);
if
(
!
pimpl
->
accountUri_
.
empty
()
&&
uri
==
pimpl
->
accountUri_
)
{
// If this is the account profile, link or copy it to the account profile path
if
(
!
fileutils
::
createFileLink
(
destPath
,
pimpl
->
accountProfilePath_
))
{
std
::
error_code
ec
;
std
::
filesystem
::
copy_file
(
destPath
,
pimpl
->
accountProfilePath_
,
ec
);
}
}
}
std
::
lock_guard
lk
{
pimpl
->
mapMutex_
};
auto
itO
=
pimpl
->
vcards_
.
find
({
deviceId
,
uri
});
if
(
itO
!=
pimpl
->
vcards_
.
end
())
pimpl
->
vcards_
.
erase
(
itO
);
if
(
code
==
uint32_t
(
libjami
::
DataTransferEventCode
::
finished
))
{
emitSignal
<
libjami
::
ConfigurationSignal
::
ProfileReceived
>
(
accountId
,
uri
,
p
ath
);
destP
ath
);
}
}
});
...
...
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