Skip to content

Commit 9fdd39c

Browse files
fix(previews): avoid large file downloads for remote movie storage
Prevent downloading entire movie files from remote storage (e.g., S3) when the 'moov atom' is located at the end of the file. Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent 319216c commit 9fdd39c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/private/Preview/Movie.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
5555
$result = null;
5656
if ($this->useTempFile($file)) {
5757
// try downloading 5 MB first as it's likely that the first frames are present there
58-
// in some cases this doesn't work for example when the moov atom is at the
59-
// end of the file, so if it fails we fall back to getting the full file
60-
$sizeAttempts = [5242880, null];
58+
// Try downloading 5 MB first, as it's likely that the first frames are present there.
59+
// In some cases this doesn't work, for example when the moov atom is at the
60+
// end of the file, so if it fails we fall back to getting the full file.
61+
// Unless the file is not local (e.g. S3) as we do not want to download the whole (e.g. 37Gb) file
62+
if ($file->getStorage()->isLocal()) {
63+
$sizeAttempts = [5242880, null];
64+
} else {
65+
$sizeAttempts = [5242880];
66+
}
6167
} else {
6268
// size is irrelevant, only attempt once
6369
$sizeAttempts = [null];

0 commit comments

Comments
 (0)