File tree 1 file changed +11
-2
lines changed
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 {
154
154
$ document ->setLastSavedVersionTime ($ file ->getFileInfo ()->getMtime ());
155
155
$ document ->setLastSavedVersionEtag ($ file ->getEtag ());
156
156
$ 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
+ }
159
168
return $ document ;
160
169
}
161
170
You can’t perform that action at this time.
0 commit comments