Commit Graph

263 Commits (1ef465f80425f3dadd47c05ae2198153723d3eec)

Author SHA1 Message Date
Robin Appelman da59fd4389
fix: misc code fixes around db sharding
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-09-09 16:59:59 +07:00
Robin Appelman b21a399d1a
fix: implement sharding compatible cleanup for various bits
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-08-28 10:27:14 +07:00
Daniel Kesselberg af6de04e9e
style: update codestyle for coding-standard 1.2.3
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-08-25 19:34:58 +07:00
ernolf a8bdd4f99b
feat(preview): move previews for imaginary pdf to own class ImaginaryPDF
Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-07-25 17:01:01 +07:00
Robin Appelman 5ea972922b
fix: explicitly filter for storageid in preview cleanup job
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-07-23 14:41:15 +07:00
Daniel Kesselberg 37454eb200
feat: log file id and path when extracting the mp3 cover fails
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-07-04 10:55:31 +07:00
Andy Scherzinger dae7c159f7
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-24 13:11:22 +07:00
Joas Schilling 4286660983
fix: Extend SVG reference check
Signed-off-by: Joas Schilling <coding@schilljs.com>
2024-05-16 10:01:33 +07:00
Joas Schilling bd6989d365
Merge pull request #44710 from nextcloud/pulsejet/imagick-check-type
fix(preview): check mime type before processing with Imagick
2024-05-15 22:13:05 +07:00
Côme Chilliet 672923f0a6
fix: Fix newly spotted psalm issues, add exhaustive typed magic properties for LDAP classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2024-04-30 09:23:58 +07:00
Varun Patil 4ab40e355f fix(preview): check mime type before processing with Imagick
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
2024-04-08 10:22:17 +07:00
Côme Chilliet ec5133b739 fix: Apply new coding standard to all files
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2024-04-02 14:16:21 +07:00
Git'Fellow 6f4d0fe79c Lower failed movie preview to info
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2024-02-03 18:52:05 +07:00
Arthur Schiwon c4f4c5a3fb
Merge pull request #41067 from Murena-SAS/preview-folder-deletes
Fix for previews not being generated sometimes
2024-01-18 11:46:12 +07:00
Joas Schilling aa5f037af7
chore: apply changes from Nextcloud coding standards 1.1.1
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
2023-11-23 10:36:13 +07:00
Christoph Wurst c9dc377ebc
Merge pull request #41395 from nextcloud/hello-emf
feat: add preview provider for emf files based on office
2023-11-16 19:48:06 +07:00
Git'Fellow ef5f7d0a90 Us strpos() only
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2023-11-15 00:04:25 +07:00
Git'Fellow 53b84732a3 Check for open_basedir before reading /proc
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2023-11-15 00:04:25 +07:00
Daniel Kesselberg 475dd60354
fix: use png as preview right away
The initial office preview implementation converted an office document with LibreOffice to PDF, used ImageMagick to extract the first page as JPEG, and passed it OC_Image.

https://github.com/nextcloud/server/pull/10198 changed the implementation to use PNG rather than PDF. OC_Image can use a PNG as a preview right away, so the ImageMagick step is unnecessary.

The registration code was updated to not ask ImageMagick if PDF is supported, as PDFs are no longer used to create office document previews.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-11-13 22:00:45 +07:00
Daniel Kesselberg b5241d5220
feat: allow multiple libreoffice invocations
LibreOffice only allows one invocation per user profile.[^1]

The office provider set the user profile to /tmp/owncloud-instanceid and therefore only one invocation per instance is allowed. This was introduced a while ago, yet it's unclear if this was intentionally or just a side effect.[^2]

The limitation on one invocation leads to the situation that the preview generation only works for a couple of files if you upload a whole folder of emf or word files.

This commit removes the limitation by using a new user profile for each preview. That's done by using instance id plus file id as postfix for getTemporaryFolder.

This has some drawbacks:

- Overload protection: If you upload 100 emf files, you may end up with 100 LibreOffice invocations. Though, you can use preview_concurrency_new to limit the number of previews that can be generated concurrently when php-sysvsem is available.
- New profile: I assume it takes a few bits to generate a fresh LibreOffice user profile. It appears that there is no way to ask LibreOffice to not create a profile and just work with the defaults. The profile will be cleaned after use by our temp manager.
- Remove the configuration option preview_office_cl_parameters:  This is not strictly necessary yet, but if you set the configuration option, the generated path for the user profile is also missing. The configuration option is not well documented (e.g., it's unclear that the last option needs to be --outdir) and actually, there should be no reason to change it after all.

[^1]: https://wiki.documentfoundation.org/UserProfile
[^2]: https://github.com/owncloud/core/pull/9784

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-11-13 21:46:31 +07:00
Daniel Kesselberg aa48a5f94f
feat: add preview provider for emf files based on office
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-11-13 12:35:54 +07:00
Simon L b681cf735a address review
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-11-03 15:27:17 +07:00
Simon L 531f5d1e4f fix semaphore guarding
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-11-03 11:47:12 +07:00
Git'Fellow d1169af129 Use \Throwable instead
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2023-11-01 16:55:19 +07:00
Git'Fellow 624986a6d5 Catch Imaginary processing errors
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2023-11-01 16:55:19 +07:00
Git'Fellow 974e86e618 Don't pass invalid streams to Imaginary
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>

Update Imaginary.php

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>

Update Imaginary.php

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2023-10-25 21:58:46 +07:00
Akhil 1d767ebff5
Check if the node has a null ID before deleting in preview watcher
Signed-off-by: Akhil <akhil@e.email>
2023-10-23 20:32:15 +07:00
Daniel Hansson da2aad598e
also remove function
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-10-02 10:54:36 +07:00
Daniel Hansson b2d105e7ec
Generate all preview sizes for Imaginary
A follow up on https://github.com/nextcloud/server/pull/40670

Based on discussions here: https://github.com/nextcloud/server/issues/38911#issuecomment-1741819188

This fixes the case were not all previews are generated, for example in the activity view: https://github.com/nextcloud/server/issues/38911#issuecomment-1738886106



Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-30 20:08:35 +07:00
JanisPlayer 80abec668b
feat: Imaginary WebP support
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2023-09-02 09:30:37 +07:00
John Molakvoæ 52590a762f
feat(files): add uploader
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2023-09-01 14:35:40 +07:00
John Molakvoæ 28725c46a8
feat: redirect to the mime icon if no preview available
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2023-08-17 18:56:38 +07:00
Simon L 46dfb84bca log imaginary errors as info to not spam the server logs
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-08-09 16:10:27 +07:00
Joas Schilling 4f7de8ed60
fix!: Remove legacy event dispatching Symfony's GenericEvent
Signed-off-by: Joas Schilling <coding@schilljs.com>
2023-07-27 09:57:51 +07:00
Christoph Wurst 14719110b9 chore: Replace \OC::$server->query with \OCP\Server::get in /lib
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2023-07-06 15:21:22 +07:00
Daniel Kesselberg 3757f390c3
feat: replace id3parser with mp3info
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-06-28 14:58:59 +07:00
Daniel Kesselberg 440f882322
feat: add width, height, crop and mode to BeforePreviewFetchedEvent
user_usage_report keeps a counter for files read.

The app uses

- OC_Filesystem::read hook
- Event listener (the legacy one) for IPreview::EVENT

Request for previews do not trigger the hook, hence the additional event listener.
The thumbnails for a list or grid view should not count, so we need the width and height.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-06-23 16:27:35 +07:00
Robin Appelman 9f1d497a0b
Merge pull request #38261 from fsamapoor/replace_strpos_calls_in_lib_private
Refactors "strpos" calls in  lib/private to improve code readability.
2023-06-01 23:10:00 +07:00
Daniel Kesselberg 0670ae607b
fix: catch errors in id3parser library
We use a forked version of getID3 to read embedded images from mp3 files to use them as previews.

If the library is unable to extract a image or fails on something different we should handle it properly.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-05-28 17:01:23 +07:00
JanisPlayer c71a3065a7 Allow to specify an imaginary key
Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com>
2023-05-22 22:19:51 +07:00
Simon L 6608f84a46
Merge pull request #36692 from nextcloud/throw-exception-to-avoid-division-by-zero
fix(preview-generator): Throw exception before dividing by zero when generating previews
2023-05-17 00:14:42 +07:00
Faraz Samapoor e7cc7653b8 Refactors "strpos" calls in lib/private to improve code readability.
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
2023-05-15 15:17:19 +07:00
Simon L d55a7c619d Fix typos in lib/public subdirectory
Found via `codespell -q 3 -S l10n -L jus ./lib/public`

Signed-off-by: luz paz <luzpaz@github.com>

Update lib/public/Accounts/IAccount.php

Signed-off-by: luz paz <luzpaz@github.com>

Signed-off-by: Simon L <szaimen@e.mail.de>
Co-Authored-By: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2023-05-10 11:56:34 +07:00
Simon L 527de8ac9d
Merge pull request #37148 from nextcloud/enh/noid/increase-imaginary-timeouts
increase imaginary timeouts as for big files the processing could take very long
2023-05-04 12:44:52 +07:00
Côme Chilliet b294edad80
Merge branch 'master' into enh/type-iconfig-getter-calls
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2023-04-20 16:52:38 +07:00
Simon L 8508865eaf
Merge pull request #37772 from nextcloud/enh/30986/follow-up
Prevent the OpenDocument preview generator from trying to open empty files
2023-04-18 12:18:14 +07:00
Simon L 800f40b71c fix php-lint
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-04-17 17:18:09 +07:00
Glandos e542e60dbc try to make linters happy
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:14 +07:00
Glandos 3440387f0f gather code from small and max preview
use directory listing in both functions to gain 25% speed on run where
every preview already exist.

Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:13 +07:00
Glandos 24c121347a Revert 0e49b40
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:13 +07:00
Glandos 06a7e90383 improve parameter doc
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:13 +07:00
Glandos 4954bead1d Ensure max preview image is not null
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:13 +07:00
Glandos b6c65fee2a php-cs-fix
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:13 +07:00
Glandos 9b4d5146d5 List preview directory only once
getCachedPreview used to call `getFile`, and this calls `getDirectoryListing` (or underlying function that list directory) to find the file. This was done for every preview spec.
Now, this is done only once at the beginning of the loop, and the array is just iterated when needed to find the correct entry.

Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-04-17 16:29:13 +07:00
Claus-Justus Heine 456679c6fb Update lib/private/Preview/Bundled.php
Co-authored-by: Carl Schwan <carl@carlschwan.eu>
2023-04-17 16:19:02 +07:00
Claus-Justus Heine b3d8363327 Prevent the OpenDocument preview generator from trying to open empty files.
Rationale: does not make sense, and triggers a deprecation error in
\ZipArchive.

Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
2023-04-17 16:19:02 +07:00
Côme Chilliet 426c0341ff
Use typed version of IConfig::getSystemValue as much as possible
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-05 12:50:08 +07:00
Simon L 0ced170567 increase imaginary timeouts as for big files the processing could take very long
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-03-09 13:15:35 +07:00
Simon L b39329c21c imaginary - fix autorotate and improve the logic
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-03-09 00:11:37 +07:00
Glandos 3bea7af7b7
fix indent 2
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-02-16 10:10:12 +07:00
Glandos 59e7ed1fad
fix indent
Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-02-15 23:40:16 +07:00
Glandos 528e66859b
Use proc_open to avoid spawning a shell
The use of `exec` will spawn a shell, using `/bin/sh` on POSIX platforms. But in restricted environment, such as AppArmor, this means giving execution to `/bin/sh`, which renders the execution restriction quite useless.
Using an array with `proc_open` reduces this, and paved the way for file streaming instead of temporary file.

Signed-off-by: Glandos <bugs-github@antipoul.fr>
2023-02-15 23:37:13 +07:00
Thomas Citharel e60888d988
fix(preview-generator): Throw exception before dividing by zero when generating previews
If the maximum preview generated gives some kind of invalid IImage, it's dimentions and filename can be set to zero.
And then later we do a division by zero to keep the aspect ratio of the previews.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2023-02-13 16:47:28 +07:00
Robin Appelman 382432d4e1
cache formats supported by imagick
turns out this can be quite slow

Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-02-13 14:57:06 +07:00
Simon L 112d516f27 imaginary - allow to generate heif, pdf and svg thumbnails
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-02-08 00:25:18 +07:00
Simon L 9a64d95676 imaginary - add tiff to supported formats
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-01-25 11:53:16 +07:00
Côme Chilliet f5c361cf44
composer run cs:fix
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-20 11:45:08 +07:00
Daniel Kesselberg 71a6030706
docs: add description how BackgroundCleanupJob.getNewPreviewLocations works
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-01-03 16:03:02 +07:00
Côme Chilliet a372564850
Fix psalm spotted errors with new requirements
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-02 15:02:28 +07:00
Varun Patil 7004c1e9f8 preview: fix HEIC orientation
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
2022-12-08 23:14:13 +07:00
Côme Chilliet a0f6a6545b
Use TimedJob from OCP instead of OC
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-12-05 10:13:34 +07:00
Varun Patil b91d6c22cf preview: respect quality in Imaginary
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
2022-12-03 07:13:49 +07:00
Richard Steinmetz 98e55ea4f0
Fix distorted previews when using imaginary
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
2022-11-11 14:21:05 +07:00
szaimen f9e9cd270d
Limit-number-of-concurrent-preview-generations
Signed-off-by: Bowen Ding <dbw9580@live.com>
Signed-off-by: szaimen <szaimen@e.mail.de>
2022-11-05 16:03:01 +07:00
Julius Härtl 07e94eca6f
Emit typed event when preview is requested
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-10-27 14:31:33 +07:00
Julius Härtl 4baf960c21
Save getting the parent node when generating the preview
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-08-24 22:20:32 +07:00
Christopher Ng 57c66bf7cb Use Image class from public API
Signed-off-by: Christopher Ng <chrng8@gmail.com>
2022-06-02 00:37:36 +07:00
John Molakvoæ 87ce03db1a
Merge pull request #32410 from nextcloud/bugfix/noid/imaginary-exception 2022-05-20 08:14:17 +07:00
Carl Schwan a5a4e0df1c Fix crop condition
Make sure that when fetching the image from the cache we don't
accidentally fetch the cropped image just because it also start with
256-256

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-05-19 17:25:32 +07:00
Julius Härtl 3742b7392d Add explicit return if getSmallImagePreview fails
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-05-19 17:01:01 +07:00
Carl Schwan 05bf8b4445 Fix cropped image generated when not asked
The $crop parameter was not propagated to the imaginary pipeline and
instead it used the smartcrop algorithm always

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-05-17 10:19:54 +07:00
John Molakvoæ 0863a3d423
Merge pull request #32315 from nextcloud/fix/noid/preview-duplicate-folder-creation 2022-05-10 10:11:24 +07:00
Richard Steinmetz 982c846b11
Fix preview generator trying to recreate an existing folder
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
2022-05-09 17:30:07 +07:00
Alexander F 00505c9a51 Set loglevel for IMagick Thumbnail error to info
Issue #32263

Signed-off-by: Alexander Fleischer <Alexander.Fleischer@tu-ilmenau.de>
2022-05-09 17:09:40 +07:00
Côme Chilliet 069477e608
Migrate more classes of lib/private to LoggerInterface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-26 16:52:52 +07:00
John Molakvoæ 3d1f22f6d8
Generate small preview straight away if Imaginary is enabled
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2022-04-06 18:55:48 +07:00
Carl Schwan b5c9189cfa Fix imaginary with rotated exif images
Now do the operation in two steps:

1. Rotate the image according the exif data
2. Do the actual operation

This should only have a performance impact on image with exif rotation
data to do the rotation. For all the other images the autorotate steps
should be almost instant.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-04-04 16:38:38 +07:00
Carl Schwan 34988cff19
Merge pull request #24166 from nextcloud/imaginary-prototype
Send images to Imaginary docker to generate previews
2022-03-18 12:32:56 +07:00
Vincent Petry 9b6a1cc8ae
Send images to imaginary docker to generate previews
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Co-Authored-by: Vincent Petry <vincent@nextcloud.com>
2022-03-17 08:24:07 +07:00
Côme Chilliet 13c11208d4
Ignore errors when searching for bundled preview
When an odt file is xml and not zip, it would throw a ValueError.
It will now just ignore this file and return null for the preview.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-28 15:43:07 +07:00
Côme Chilliet 0daec4b27e
Fix tmp file cleaning for bundled previews
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-24 14:55:57 +07:00
Côme Chilliet d43dbfa0f2
Fix typing in OC\Preview\Movie
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-24 14:55:48 +07:00
Côme Chilliet ebe731f014
Fix typing in OC\Preview
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-24 14:42:55 +07:00
UmbrellaCodr a0d7e27789
reduce 'Movie preview generation failed Output' log errors
for movies under 5 seconds

Signed-off-by: UmbrellaCodr <umbrella@biohazard.cc>

Update lib/private/Preview/Movie.php

Co-authored-by: Simon L. <szaimen@e.mail.de>
2022-02-03 17:52:37 +07:00
Carl Schwan 6312c0df69
Check style update
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-13 00:19:07 +07:00
Julius Härtl 6f986519fe
Merge pull request #28610 from nextcloud/enh/preview-cleanup-query 2021-12-28 13:20:02 +07:00
Côme Chilliet 3631789651
Fix resource usages in OC_Image
This makes sure using resource or GdImage (PHP>=8) behaves the same.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2021-10-28 17:48:43 +07:00
J0WI 047cab8dd2 Use findBinaryPath for previews
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
2021-10-23 23:15:42 +07:00
Vincent Petry 24e0255378
Fall back to full file for video previews
If the first 5 MB are not enough to grab a useful frame for the
thumbnail preview, fall back to reading the full file.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-09-18 10:53:00 +07:00
Julius Härtl 0670118470
Use storage filter when fetching previews to cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-08-26 22:03:05 +07:00