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