File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -154,8 +154,17 @@ public function createDocument(File $file): Document {
154154 $ document ->setLastSavedVersionTime ($ file ->getFileInfo ()->getMtime ());
155155 $ document ->setLastSavedVersionEtag ($ file ->getEtag ());
156156 $ document ->setBaseVersionEtag ($ file ->getEtag ());
157- $ document = $ this ->documentMapper ->insert ($ document );
158- $ this ->cache ->set ('document-version- ' .$ document ->getId (), 0 );
157+ try {
158+ $ document = $ this ->documentMapper ->insert ($ document );
159+ $ this ->cache ->set ('document-version- ' .$ document ->getId (), 0 );
160+ } catch (Exception $ e ) {
161+ if ($ e ->getReason () === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION ) {
162+ // Document might have been created in the meantime
163+ return $ this ->documentMapper ->find ($ file ->getFileInfo ()->getId ());
164+ }
165+
166+ throw $ e ;
167+ }
159168 return $ document ;
160169 }
161170
You can’t perform that action at this time.
0 commit comments