File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 2222use OCA \Files_Versions \Versions \IVersion ;
2323use OCA \Files_Versions \Versions \IVersionBackend ;
2424use OCA \Files_Versions \Versions \IVersionsImporterBackend ;
25+ use OCP \AppFramework \Db \DoesNotExistException ;
2526use OCP \Constants ;
2627use OCP \Files \File ;
2728use OCP \Files \FileInfo ;
@@ -392,7 +393,15 @@ public function createVersionEntity(File $file): void {
392393 }
393394
394395 public function updateVersionEntity (File $ sourceFile , int $ revision , array $ properties ): void {
395- $ versionEntity = $ this ->collectiveVersionMapper ->findVersionForFileId ($ sourceFile ->getId (), $ revision );
396+ try {
397+ $ versionEntity = $ this ->collectiveVersionMapper ->findVersionForFileId ($ sourceFile ->getId (), $ revision );
398+ } catch (DoesNotExistException $ e ) {
399+ // The version entity can be missing when a file is written immediately
400+ // after being copied (e.g. by the Text app's NodeCopiedListener clearing
401+ // attachment IDs). Fall back to creation to stay consistent.
402+ $ this ->createVersionEntity ($ sourceFile );
403+ return ;
404+ }
396405
397406 if (isset ($ properties ['timestamp ' ])) {
398407 $ versionEntity ->setTimestamp ($ properties ['timestamp ' ]);
You can’t perform that action at this time.
0 commit comments