5050 */
5151class MetaService {
5252 private $ metaMapper ;
53+ private $ noteUtil ;
5354
54- public function __construct (MetaMapper $ metaMapper ) {
55+ public function __construct (MetaMapper $ metaMapper, NoteUtil $ noteUtil ) {
5556 $ this ->metaMapper = $ metaMapper ;
57+ $ this ->noteUtil = $ noteUtil ;
5658 }
5759
5860 public function deleteByNote (int $ id ) : void {
@@ -130,7 +132,7 @@ private function createMeta(string $userId, Note $note) : Meta {
130132 }
131133
132134 private function updateIfNeeded (Meta &$ meta , Note $ note , bool $ forceUpdate ) : bool {
133- $ generateContentEtag = $ forceUpdate ;
135+ $ generateContentEtag = $ forceUpdate || ! $ meta -> getContentEtag () ;
134136 $ fileEtag = $ note ->getFileEtag ();
135137 // a changed File-ETag is an indicator for changed content
136138 if ($ fileEtag !== $ meta ->getFileEtag ()) {
@@ -155,9 +157,14 @@ private function updateIfNeeded(Meta &$meta, Note $note, bool $forceUpdate) : bo
155157
156158 // warning: this is expensive
157159 private function generateContentEtag (Note $ note ) : string {
158- return Util::retryIfLocked (function () use ($ note ) {
159- return md5 ($ note ->getContent ());
160- }, 3 );
160+ try {
161+ return Util::retryIfLocked (function () use ($ note ) {
162+ return md5 ($ note ->getContent ());
163+ }, 3 );
164+ } catch (\Throwable $ t ) {
165+ $ this ->noteUtil ->logException ($ t );
166+ return '' ;
167+ }
161168 }
162169
163170 // this is not expensive, since we use the content ETag instead of the content itself
0 commit comments