File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 26
26
namespace OCA \DAV \Upload ;
27
27
28
28
use OCA \DAV \Connector \Sabre \Directory ;
29
+ use OCA \DAV \Connector \Sabre \Exception \Forbidden ;
29
30
use Sabre \DAV \Exception \BadRequest ;
30
31
use Sabre \DAV \Exception \NotFound ;
31
32
use Sabre \DAV \INode ;
@@ -87,13 +88,16 @@ public function beforeMove($sourcePath, $destination) {
87
88
* @return bool|void false to stop handling, void to skip this handler
88
89
*/
89
90
public function performMove ($ path , $ destination ) {
90
- if (!$ this ->server ->tree ->nodeExists ($ destination )) {
91
- // skip and let the default handler do its work
92
- return ;
93
- }
94
-
95
91
// do a move manually, skipping Sabre's default "delete" for existing nodes
96
- $ this ->server ->tree ->move ($ path , $ destination );
92
+ try {
93
+ $ this ->server ->tree ->move ($ path , $ destination );
94
+ } catch (Forbidden $ e ) {
95
+ $ sourceNode = $ this ->server ->tree ->getNodeForPath ($ path );
96
+ if ($ sourceNode instanceof FutureFile) {
97
+ $ sourceNode ->delete ();
98
+ }
99
+ throw $ e ;
100
+ }
97
101
98
102
// trigger all default events (copied from CorePlugin::move)
99
103
$ this ->server ->emit ('afterMove ' , [$ path , $ destination ]);
You can’t perform that action at this time.
0 commit comments