Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
9d634fa1
Commit
9d634fa1
authored
Nov 07, 2016
by
Vincent Petry
Committed by
Thomas Müller
Nov 07, 2016
Browse files
Skip broken shares when transferring ownership (#26527)
parent
adb7572c
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/files/lib/Command/TransferOwnership.php
View file @
9d634fa1
...
...
@@ -225,22 +225,28 @@ class TransferOwnership extends Command {
$progress
=
new
ProgressBar
(
$output
,
count
(
$this
->
shares
));
foreach
(
$this
->
shares
as
$share
)
{
if
(
$share
->
getSharedWith
()
===
$this
->
destinationUser
)
{
// Unmount the shares before deleting, so we don't try to get the storage later on.
$shareMountPoint
=
$this
->
mountManager
->
find
(
'/'
.
$this
->
destinationUser
.
'/files'
.
$share
->
getTarget
());
if
(
$shareMountPoint
)
{
$this
->
mountManager
->
removeMount
(
$shareMountPoint
->
getMountPoint
());
}
$this
->
shareManager
->
deleteShare
(
$share
);
}
else
{
if
(
$share
->
getShareOwner
()
===
$this
->
sourceUser
)
{
$share
->
setShareOwner
(
$this
->
destinationUser
);
}
if
(
$share
->
getSharedBy
()
===
$this
->
sourceUser
)
{
$share
->
setSharedBy
(
$this
->
destinationUser
);
}
try
{
if
(
$share
->
getSharedWith
()
===
$this
->
destinationUser
)
{
// Unmount the shares before deleting, so we don't try to get the storage later on.
$shareMountPoint
=
$this
->
mountManager
->
find
(
'/'
.
$this
->
destinationUser
.
'/files'
.
$share
->
getTarget
());
if
(
$shareMountPoint
)
{
$this
->
mountManager
->
removeMount
(
$shareMountPoint
->
getMountPoint
());
}
$this
->
shareManager
->
deleteShare
(
$share
);
}
else
{
if
(
$share
->
getShareOwner
()
===
$this
->
sourceUser
)
{
$share
->
setShareOwner
(
$this
->
destinationUser
);
}
if
(
$share
->
getSharedBy
()
===
$this
->
sourceUser
)
{
$share
->
setSharedBy
(
$this
->
destinationUser
);
}
$this
->
shareManager
->
updateShare
(
$share
);
$this
->
shareManager
->
updateShare
(
$share
);
}
}
catch
(
\
OCP\Files\NotFoundException
$e
)
{
$output
->
writeln
(
'<error>Share with id '
.
$share
->
getId
()
.
' points at deleted file, skipping</error>'
);
}
catch
(
\
Exception
$e
)
{
$output
->
writeln
(
'<error>Could not restore share with id '
.
$share
->
getId
()
.
':'
.
$e
->
getTraceAsString
()
.
'</error>'
);
}
$progress
->
advance
();
}
...
...
Write
Preview
Markdown
is supported
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