Commit Graph

10646 Commits

Author SHA1 Message Date
evazion
52bf4a3a6b maintenance: break maintenance tasks into individual jobs.
Break the hourly/daily/weekly/monthly maintenance tasks down into
individual delayed jobs. This way if one task fails, it won't prevent
other tasks from running. Also, jobs can be run in parallel, and can be
individually retried if they fail.
2021-09-26 20:38:30 -05:00
evazion
7d3e491dc6 posts: stop autotagging huge_filesize.
https://danbooru.donmai.us/forum_topics/19526
2021-09-26 18:26:38 -05:00
evazion
1075277d36 posts: remove unused methods. 2021-09-26 08:15:17 -05:00
evazion
01cdc7da7f media assets: add status column. 2021-09-26 08:06:13 -05:00
evazion
3d30bfd69d media assets: add duration column.
Add a column for tracking the duration (length) of videos and
animations. The duration will be null for static images.
2021-09-26 07:45:29 -05:00
evazion
ab3f35580f metadata: move metadata parsing into ExifTool::Metadata.
Move the metadata parsing code from MediaAsset to ExifTool::Metadata so
we can use it outside the context of a MediaAsset, in particular when
dealing with a MediaFile that hasn't been saved to disk yet.
2021-09-26 07:19:36 -05:00
evazion
960817e9fe posts: don't send cookies for thumbnail requests.
Set `crossorigin="anonymous"` on the <img> tag for thumbnails. This
makes it so we don't send session cookies in requests for thumbnails.
Since images are served from cdn.donmai.us, and since session cookies
are set on *.donmai.us, session cookies are sent by default with every
thumbnail request.

Not sending cookies saves up to 1kb of overhead per thumbnail request
(in reality, it's less than this because of HTTP/2 multiplexing and
header compression).
2021-09-26 07:19:36 -05:00
evazion
7d3eebaced posts: purge all cached URLs when post is regenerated
Fix not all URLs being purged from Cloudflare when a post is
regenerated.
2021-09-26 01:21:32 -05:00
evazion
63240e0446 Remove config/spring.rb.
We no longer use Spring (https://github.com/rails/spring).
2021-09-25 08:00:52 -05:00
evazion
04cd6d0d3f newrelic: log screen resolution and pixel density.
Log the user's screen resolution and pixel density so we can make better
decisions about which screen sizes to support.
2021-09-25 06:46:25 -05:00
evazion
51bc953383 post preview component: remove workaround for blank width/height.
Remove workaround for old posts that had a null width or height. These
posts were fixed a while ago.
2021-09-25 06:34:15 -05:00
evazion
6f02918676 Merge pull request #4887 from nonamethanks/update-artist-finder
Update artist finder blacklist
2021-09-24 08:54:48 -05:00
evazion
c183237b6b docker: update docker-compose file.
* Listen on port 3000 instead of port 80. Port 80 is prone to conflicts
  with other webservers.

* Use the production version of the Danbooru Docker image. It's less
  likely to have bugs than master.

* Fix the autoinstall script to work with `curl ... | sh`.

* Lower PUMA_WORKERS to 1 to reduce memory usage.
2021-09-24 08:40:33 -05:00
evazion
463e6d7b49 artists: fix deadlock when banning artists.
Caused by d854bf6b. Banning an artist would deadlock because it was
performed in a transaction, which didn't work with the `parallel_each`
inside the "create an implication to banned_artist" step.
2021-09-24 08:40:33 -05:00
evazion
9d62f71cd9 ci: prevent running multiple Docker builds at once. 2021-09-24 08:40:33 -05:00
evazion
e8a09bc400 js: fix eslint warnings. 2021-09-24 08:40:33 -05:00
nonamethanks
16f76fe396 Update artist finder blacklist 2021-09-24 14:50:19 +02:00
evazion
dd9c4dd04a Fix #4846: Codeclimate integration broken 2021-09-24 07:46:00 -05:00
evazion
74b03a7bd0 posts: fix incorrect exif rotation for PNGs.
Fix a bug where where PNG images could be incorrectly detected as
exif-rotated. This would happen when a PNG contained the
IFD0:Orientation flag. It's technically possible for a PNG to contain
this flag, but it's ignored by libvips and by browsers.

post #3762340 (nsfw) is an example of a PNG like this.

The fix is to use `autorot` to let libvips apply the rotation instead of
trying to interpret the exif data ourselves. Note that libvips-8.9 has a
bug where it doesn't strip the orientation flag after applying
`autorot`, which leads to the image being incorrectly rotated a second
time when generating the thumbnail. Use libvips-8.11 instead.
2021-09-23 00:10:00 -05:00
evazion
9c0ab258cb Upgrade libvips to 8.11.3. 2021-09-22 23:56:59 -05:00
evazion
e7a455ea44 Merge pull request #4884 from nonamethanks/remove_long_image
Posts: stop autotagging long_image
2021-09-22 23:09:08 -05:00
GlassedSilver
0dd77b0f7f Bump Ruby to 3.0.2 in INSTALL.debian 2021-09-22 23:02:13 -05:00
evazion
ee5cd8330d uploads: fix exception when pruning expired uploads.
Hourly pruning of expired uploads was failing because of nil deference
errors in `media_asset.destroy!`. There are various cases where an
upload doesn't have a media asset, for example when the source url
fails to download or when the upload is of an invalid filetype.
2021-09-22 13:24:27 -05:00
evazion
259e3fde68 ci: fix issue with betabooru deploy workflow.
Just trigger on pushes to the betabooru branch instead of on the Docker
image being built. The workflow_run event keeps triggering on the master
branch even though it's supposed to only trigger on the betabooru
branch. This makes it fail because it doesn't have access to the secrets
in the betabooru environment.

This does mean the deploy will fail if the image hasn't been previously
built by a push to master first.
2021-09-22 12:33:42 -05:00
evazion
6740ef17ab posts: fix detection of exif_rotation tag.
`IFD0:Orientation` is the orientation of the main image.
`IFD1:Orientation` is the orientation of the embedded thumbnail, if it
has one. Using `IFD1:Orientation` was incorrect here because some images
have a non-rotated main image but a rotated thumbnail. Post #1023563 is
an example.
2021-09-22 11:17:28 -05:00
evazion
b378785582 Fix #3692: Rotate pictures based on metadata
Rotate the image based on the EXIF orientation flag when generating
thumbnails and samples.

Also fix the width and height to be calculated correctly for rotated
images. Vips gives us the unrotated width and height of the image; we
have to detect whether the image is rotated and swap the width and
height manually to correct them. For example, if an image with the
"Rotate 90 CW" flag is 100x500 before rotation, then after rotation it's
500x100. This should fix #4883 (Exif rotation breaks Javascript fit-to-window)

We also have to fix it so that regenerating a post updates the width and
height of the post, in the event that it's a rotated image.

Finally we set `image-orientation: from-image;` even though it's
probably not necessary.
2021-09-22 11:12:50 -05:00
evazion
9b6c429d4c ci: automatically deploy betabooru on push.
Make it so that on every push to the `betabooru` branch, the latest
commit is automatically deployed to https://betabooru.donmai.us.
2021-09-22 09:31:26 -05:00
evazion
52f3c22173 rake: clean up rake tasks.
* Make danbooru:images:validate task run in parallel.
* Remove task for regenerating thumbnails.
* Move all rake tasks into same file.
* Add usage instructions.
2021-09-22 05:36:22 -05:00
evazion
d2ba355371 Remove unused SimpleForm scaffold template. 2021-09-22 04:52:29 -05:00
evazion
ac12efb636 tests: fix test failures when running without API keys.
Fix the test suite failing when trying to run it in the default state
with no config file or API keys configured. Most source sites require
API keys or login credentials to be set in order to work. Skip these
tests when credentials aren't configured.
2021-09-22 04:33:36 -05:00
nonamethanks
ce8c8e1ab7 Posts: stop autotagging long_image 2021-09-22 11:16:52 +02:00
evazion
3a05b7e832 docker: add less and tini to base image.
Add `less` to the Docker image to fix an issue with running `bin/rails console`.
The console uses Pry[1], which has an issue where it pipes long output
through `less`, but it tries to use the -X option, which is only
supported by GNU less, not Busybox less. There's a open bug about this
in the Pry repo dating back to 2014[2].

Add `tini` and use it as the Docker entrypoint to ensure we forward
signals to child processes and reap zombie children properly. This fixes
an issue where if you ran something like:

  docker run ghcr.io/danbooru/danbooru bash -c 'bin/rails db:test:prepare && bin/rails test'

Then you couldn't use control-C to stop the container. This was because
bash wasn't forwarding signals to its children, and because by default,
programs running as PID 1 ignore SIGINT and SIGTERM. See [3][4] for details.

1: https://github.com/pry/pry
2: https://github.com/pry/pry/issues.1248
3: https://github.com/krallin/tini/issues.8
4: https://gist.github.com/StevenACoffman/41fee08e8782b411a4a26b9700ad7af5#dont-run-pid-1
2021-09-22 02:52:36 -05:00
evazion
8738d8a645 Remove deletion appeal thread updater.
It was already disabled before, remove it completely now.
2021-09-22 01:57:45 -05:00
evazion
28d2753c53 BURs: don't allow builders to edit or reject BURs by other users.
Only admins can edit or reject BURs by other users now. The BUR creator
can still edit or reject their own BURs.
2021-09-22 00:34:44 -05:00
evazion
5af21f03de versions: default ARCHIVE_DATABASE_URL to DATABASE_URL.
Make it so that when ARCHIVE_DATABASE_URL isn't set, it defaults to
DATABASE_URL. In other words, if you don't have a separate archive
database configured, then default to using the main database for
post/pool versions.

Fixes an issue where running the test suite would fail if you didn't
explicitly set ARCHIVE_DATABASE_URL because it tried to use
`archive_test` as the post/pool versions database name.
2021-09-22 00:34:28 -05:00
evazion
d953ca694c docker: remove docker-compose.test.yaml
This was previously used to run the test suite with Docker Compose under
CircleCI. We no longer use this since switching to Github Actions.
2021-09-21 21:35:45 -05:00
evazion
3a0614bb55 db: recreate post versions and pool versions tables.
Add the post and pool versions tables back. Currently only used by the
test suite to make it easier to run. Not yet used for production.
2021-09-21 12:35:46 -05:00
evazion
c69ba54b5a Fix #4442: Autotag image metadata.
Autotag `greyscale`, `non-repeating_animation`, and `exif_rotation`.

Note that this does not detect all (or even most) greyscale images.
Artists often save greyscale images as RGB instead of as greyscale.
2021-09-21 11:18:06 -05:00
evazion
d5981754c4 posts: automatically tag animated_gif & animated_png on tag edit.
Automatically tag animated_gif and animated_png when a post is edited.
Add them back if the user tries to remove them from an animated post,
or remove them if the user tries to add them to a non-animated post.

Before we added these tags at upload time, but it was possible for users
to remove them after upload, or to incorrectly add them to non-animated
posts. They were added at upload time because we couldn't afford to open
the file and parse the metadata on every tag edit. Now that we save the
metadata in the database, we can do this.

This also makes it so you can't tag ugoira on non-ugoira files.

Known bug: it's possible to have an animated GIF where every frame is
identical. Post #3770975 is an example. This will be detected as an
animated GIF even though visually it doesn't appear to be animated.

Fixes #4041: Animated_gif tag not added to preprocessed uploads
2021-09-21 08:26:02 -05:00
evazion
4d0580b160 MediaFile: remove old libvips compatibility code.
Remove code for working with older versions of libvips. This makes
libvips 8.10+ a hard requirement. Older versions were already broken and
failed certain tests in the test suite.
2021-09-21 07:47:48 -05:00
evazion
ae7d964bf1 MediaFile: replace APNGInspector with ExifTool.
Replace our own handwritten APNG parser with ExifTool. This makes
ExifTool a hard requirement for handling APNGs.
2021-09-21 07:47:45 -05:00
evazion
273be55de8 Upgrade to Ruby 3.0.2. 2021-09-21 02:56:23 -05:00
evazion
c6bf3e7934 BURs: don't automatically retry failed BURs.
If a bulk update job fails, don't automatically retry it. Retrying it
will clobber the original error message if it fails again.
2021-09-20 16:33:23 -05:00
evazion
1d8a3bf09f BURs: allow failed BURs to be reapproved.
Fix it so that you can reapprove a failed BUR to run it again. Before
this would fail because it would end up trying to create the aliases
or implications again, which would fail because they already existed.
Now it ignores when an alias or implication already exists. It will
however finish tagging the posts if they haven't been fully moved.
2021-09-20 16:29:38 -05:00
evazion
0fed4b557b Remove Unicorn.
No longer used now that we use Puma in production. If you still used
Unicorn in your install, switch to `bin/rails server` instead. See
config/puma.rb for config settings.
2021-09-20 06:17:57 -05:00
evazion
68769c7c3b Remove Capistrano.
No longer used now that we use Kubernetes to deploy the site instead of
Capistrano.

If you run your own installation of Danbooru, and you used Capistrano to
deploy your site, it is recommended that you switch to either the Docker
Compose file (for personal installs), the Procfile (for non-Dockerized,
development environments), or Kubernetes (for production environments;
see https://github.com/danbooru/danbooru-infrastructure/tree/master/k8s
for Danbooru's production configuration).
2021-09-20 04:57:41 -05:00
evazion
b7b6797b18 tests: skip weibo tests in CI.
Weibo tests keep failing randomly in CI. Give up and skip them to
prevent them from always marking commits as failed.
2021-09-20 02:17:31 -05:00
evazion
98b3c82ac5 tests: fix deadlock during artist ban test.
The artist ban tests deadlocked because of a weird interaction between
threads and database transactions when tagging posts in parallel. Add a
hack to work around it.
2021-09-20 02:09:14 -05:00
evazion
5995571885 clockwork: add heartbeat task.
Add a cron job that touches a file every minute so we can be sure
clockwork (the cronjob daemon) is still running.
2021-09-20 01:32:12 -05:00
evazion
051f2be93f gems: remove whenever gem.
We're now using the `clockwork` gem for cronjobs in production. See
config/initializers/clockwork.rb.
2021-09-20 01:30:52 -05:00