Skip to content

Commit

Permalink
Don't do unnecessary extra mimetype detection
Browse files Browse the repository at this point in the history
We take the highest-priority detection anyway, so just stop running
detections when we get a result.
  • Loading branch information
zerocrates committed Aug 10, 2023
1 parent deb0277 commit 064f1be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions application/libraries/Omeka/File/MimeType/Detect.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ public function detect()
// Cache the MIME type, keyed to the strategy class name.
$this->_mimeTypes[get_class($strategy)] = $mimeType;

// Set the definitive MIME type if it's not ambiguous and if it
// hasn't already been detected by a previous strategy.
if (!in_array($mimeType, $this->_ambiguousMimeTypes) && !$this->_mimeType) {
// Set the definitive MIME type if it's not ambiguous, and
// don't run any further strategies
if (!in_array($mimeType, $this->_ambiguousMimeTypes)) {
$this->_mimeType = $mimeType;
break;
}
}

Expand Down

0 comments on commit 064f1be

Please sign in to comment.