@@ -56,6 +56,7 @@ public function initialize(Server $server): void {
56
56
$ server ->on ('method:PUT ' , [$ this , 'httpPut ' ]);
57
57
$ server ->on ('method:DELETE ' , [$ this , 'httpDelete ' ]);
58
58
$ server ->on ('afterMove ' , [$ this , 'afterMove ' ]);
59
+ $ server ->on ('afterCopy ' , [$ this , 'afterCopy ' ]);
59
60
60
61
$ this ->server = $ server ;
61
62
}
@@ -117,7 +118,7 @@ public function httpDelete(RequestInterface $request, ResponseInterface $respons
117
118
return true ;
118
119
}
119
120
120
- public function afterMove (string $ source , string $ destination ) {
121
+ public function afterMove (string $ source , string $ destination ): void {
121
122
// source node does not exist anymore, thus use still existing parent
122
123
$ sourceParentNode = dirname ($ source );
123
124
$ sourceParentNode = $ this ->server ->tree ->getNodeForPath ($ sourceParentNode );
@@ -145,4 +146,24 @@ public function afterMove(string $source, string $destination) {
145
146
$ this ->symlinkManager ->deleteSymlink ($ destinationInfo );
146
147
}
147
148
}
149
+
150
+ public function afterCopy (string $ source , string $ destination ): void {
151
+ $ sourceNode = $ this ->server ->tree ->getNodeForPath ($ source );
152
+ if (!$ sourceNode instanceof \OCA \DAV \Connector \Sabre \Node) {
153
+ throw new \Sabre \DAV \Exception \NotImplemented (
154
+ 'Unable to check if copied file is a symlink! ' );
155
+ }
156
+ $ destinationNode = $ this ->server ->tree ->getNodeForPath ($ destination );
157
+ if (!$ destinationNode instanceof \OCA \DAV \Connector \Sabre \Node) {
158
+ throw new \Sabre \DAV \Exception \NotImplemented (
159
+ 'Unable to set symlink information on copy destination! ' );
160
+ }
161
+
162
+ $ sourceInfo = $ sourceNode ->getFileInfo ();
163
+ $ destinationInfo = $ destinationNode ->getFileInfo ();
164
+
165
+ if ($ this ->symlinkManager ->isSymlink ($ sourceInfo )) {
166
+ $ this ->symlinkManager ->storeSymlink ($ destinationInfo );
167
+ }
168
+ }
148
169
}
0 commit comments