Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make VideoHandler support optional #1439

Merged
merged 8 commits into from
Aug 6, 2022
Merged

Make VideoHandler support optional #1439

merged 8 commits into from
Aug 6, 2022

Conversation

kamil4
Copy link
Contributor

@kamil4 kamil4 commented Aug 3, 2022

Fixes #1438

This is a semi-draft PR:

  • I fixed only the case of uploading a regular video file but I see that VideoHandler is also used for Google Motion Pictures. I left the latter as-is as I don't understand how that part works and what (if anything) we can do about it.
  • By catching the exception, we prevent a message about missing FFmpeg from being generated in the logs. It seems like it would be useful to have it there though under these circumstances, but I wasn't sure what the "approved" way of doing it is these days. @nagmat84?

@kamil4 kamil4 requested a review from a team August 3, 2022 22:19
@codecov
Copy link

codecov bot commented Aug 3, 2022

Codecov Report

Merging #1439 (05fbd50) into master (89fcba4) will decrease coverage by 0.75%.
The diff coverage is 100.00%.

Copy link
Collaborator

@nagmat84 nagmat84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me with respect to the reported issue.

Maybe we should wrap the whole if-then-else-branch into the try-block? This would also allow to upload regular photos which are too broken to generate thumbs but maybe still viewable by a browser. But I don't know if that case really exist.

We should also have a test which tries to upload a video with FFMpeg disabled and which asserts that the upload still succeeds, that no thumbnail has been generated and a log entry has been made. But I can also write the test tomorrow independently of this PR.

@nagmat84

This comment was marked as resolved.

@kamil4
Copy link
Contributor Author

kamil4 commented Aug 4, 2022

@nagmat84: I made some changes along the lines you suggested. Logging works now. An existing testcase (testBrokenGoogleMotionPhotoUpload) triggers now though -- I decided to leave it up to you to figure out what to do about it.

I also added a testcase for uploading a video file without ffmpeg (or exiftool for that matter, to ensure no video metadata). It works, though maybe it's not as tight as you would like (I don't believe it actually checks if there are no thumbnails?).

Copy link
Collaborator

@nagmat84 nagmat84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some ideas.

tests/Feature/PhotosAddHandlerTestAbstract.php Outdated Show resolved Hide resolved

Configs::set(self::CONFIG_HAS_FFMPEG, $hasFFMpeg);
Configs::set(self::CONFIG_HAS_EXIF_TOOL, $hasExifTool);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should additionally assert that the expected error message, e.g. "FFMpeg is disabled by configuration", can be found in the logs?

To this end we could clear the log table at the beginning of the test with DB::tables('logs)->delete(). At the end of the test we do a count-query and assert that we found an entry, e.g. something like

$numErrorMsg = DB::tables('logs)->where('message', 'like', '%FFMpeg is disabled by configuration%')->count();
self::assertEquals(1, $numErrorMsg);

But maybe this would make the test too strict? I am unsure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't do it myself (testing for log messages seems a little overly prescriptive to me) but feel free to add a commit to that effect to this PR if you want.

@nagmat84 nagmat84 merged commit ba99f20 into master Aug 6, 2022
@nagmat84 nagmat84 deleted the fix-1438 branch August 6, 2022 09:17
ildyria added a commit that referenced this pull request Aug 6, 2022
* add JetBrain Open Source Community Support (#1442)

* add JetBrain Open Source Community Support

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>
Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com>

* Make VideoHandler support optional (#1439)

* Make VideoHandler support optional

* Changes recommended by nagmat84

* Add a testcase for video upload without ffmpeg

* Fix new testcase

* Fix a typo

* Update tests/Feature/PhotosAddHandlerTestAbstract.php

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>

* Check for error message that FFmpeg is disabled

* Fixed Google Motion Photo test

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>

* Apply fixes from PHP-CS-Fixer

Co-authored-by: Benoît Viguier <ildyria@users.noreply.github.com>
Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>
Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com>
Co-authored-by: Kamil Iskra <kamil.01482@iskra.name>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: github-actions[bot] <action@github.com>
nagmat84 added a commit that referenced this pull request Sep 17, 2022
* Support API tokens per user

* Do not require Accept and Content-Type headers

* Fix 500 on user creation

* Recompile

* Fix some reviews

* Undo Content-Type and Accept change

* Fix phpstan

* Fix phpstan

* Fix phpstan 3

* add support for disabling the token completely rather than letting it set as a random value

* disable-enable FK

* add tests

* remove unused variable

* Translate and add strings

* Fix security issue during migration that gives admin perms to api_key

* Fix locale

* Sync frontend

* Suggestions

* Apply suggestions from code review

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>

* Apply suggestions

* Recompile frontend

* Fix perms

* Fix lint

* Improve check

* Simplify middleware

* Assert JSON

* fix format

* Apply fixes from PHP-CS-Fixer (#1444)

* add JetBrain Open Source Community Support (#1442)

* add JetBrain Open Source Community Support

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>
Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com>

* Make VideoHandler support optional (#1439)

* Make VideoHandler support optional

* Changes recommended by nagmat84

* Add a testcase for video upload without ffmpeg

* Fix new testcase

* Fix a typo

* Update tests/Feature/PhotosAddHandlerTestAbstract.php

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>

* Check for error message that FFmpeg is disabled

* Fixed Google Motion Photo test

Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>

* Apply fixes from PHP-CS-Fixer

Co-authored-by: Benoît Viguier <ildyria@users.noreply.github.com>
Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>
Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com>
Co-authored-by: Kamil Iskra <kamil.01482@iskra.name>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: github-actions[bot] <action@github.com>

* Hash tokens

* Sync frontend

* Tmp commit to find out why it's failing

* Second try to find failure

* I'm pretty stupid at all

* Fix db errors

* Fix phpstan

* Fix phpstan 2

* Fix phpstan 3

* Fix test

* Add tests and fix issues as guest

* sync frontend

* fix phpdoc

* Update locales and sync frontedn

* Fix duplicated keys

* Sync frontend

* Add getAuthenticatedUser test

* Don't send token with user, fix locales, synced frontend

* Make PHPStan happy about something toally unrelated

* Sync frontend

* fix sync

* Remove HasUserMiddleware

* Fix tests

* Added custom guard to handle session or token

* Avoid unintended login as admin

* Keep token-based authentication stateless + Fix tests

* Added test for logout

* Don't drop table

* Recompile frontend

* Revert "Recompile frontend"

This reverts commit 039d72f.

* Only migrate if not exists

* Sync frontend to master

* Undo change

Co-authored-by: ildyria <beviguier@gmail.com>
Co-authored-by: Matthias Nagel <matthias.h.nagel@posteo.de>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Benoît Viguier <ildyria@users.noreply.github.com>
Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com>
Co-authored-by: Kamil Iskra <kamil.01482@iskra.name>
Co-authored-by: github-actions[bot] <action@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Video upload fails with error: FFmpeg is disabled by configuration
2 participants