@@ -125,6 +125,22 @@ public function pre_touch_hook(Node $node): void {
125125 }
126126
127127 public function touch_hook (Node $ node ): void {
128+ // Do not handle folders.
129+ if ($ node instanceof Folder) {
130+ return ;
131+ }
132+
133+ if ($ node instanceof NonExistingFile) {
134+ $ this ->logger ->error (
135+ 'Failed to create or update version for {path}, node does not exist ' ,
136+ [
137+ 'path ' => $ node ->getPath (),
138+ ]
139+ );
140+
141+ return ;
142+ }
143+
128144 $ previousNode = $ this ->nodesTouched [$ node ->getId ()] ?? null ;
129145
130146 if ($ previousNode === null ) {
@@ -152,7 +168,22 @@ public function touch_hook(Node $node): void {
152168
153169 public function created (Node $ node ): void {
154170 // Do not handle folders.
155- if ($ node instanceof File && $ this ->versionManager instanceof INeedSyncVersionBackend) {
171+ if (!($ node instanceof File)) {
172+ return ;
173+ }
174+
175+ if ($ node instanceof NonExistingFile) {
176+ $ this ->logger ->error (
177+ 'Failed to create version for {path}, node does not exist ' ,
178+ [
179+ 'path ' => $ node ->getPath (),
180+ ]
181+ );
182+
183+ return ;
184+ }
185+
186+ if ($ this ->versionManager instanceof INeedSyncVersionBackend) {
156187 $ this ->versionManager ->createVersionEntity ($ node );
157188 }
158189 }
@@ -190,6 +221,17 @@ public function post_write_hook(Node $node): void {
190221 return ;
191222 }
192223
224+ if ($ node instanceof NonExistingFile) {
225+ $ this ->logger ->error (
226+ 'Failed to create or update version for {path}, node does not exist ' ,
227+ [
228+ 'path ' => $ node ->getPath (),
229+ ]
230+ );
231+
232+ return ;
233+ }
234+
193235 $ writeHookInfo = $ this ->writeHookInfo [$ node ->getId ()] ?? null ;
194236
195237 if ($ writeHookInfo === null ) {
0 commit comments