Commit Graph

1079 Commits

Author SHA1 Message Date
WithoutPants f292238e7f
Only close DB if not nil (#1749) 2021-09-21 21:57:50 +10:00
dependabot[bot] 25182997f1
Bump axios from 0.21.1 to 0.21.2 in /ui/v2.5 (#1745)
Bumps [axios](https://github.com/axios/axios) from 0.21.1 to 0.21.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.21.1...v0.21.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-21 20:32:55 +10:00
InfiniteTF a4ed9515c7
Support subpaths when serving stash through a reverse proxy (#1719)
* Support subpaths when serving stash through a reverse proxy
* Add README documentation

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2021-09-21 14:12:10 +10:00
WithoutPants f3c8407c40
Cancel in progress builds when new action starts 2021-09-21 12:05:46 +10:00
gitgiggety 3e526a49a4
Add indexes for path and checksum to images (#1740)
* Add indexes for path and checksum to images

The scenes table has unique indexes/constraints on path and checksum
colums. The images table doesn't, which doesn't really make sense, as
scanning uses these colums extensively which warrents an index, and both
should be unique as well.

Adding these indexes thus heavily improves the scanning tasks
performance. On a database containing 4700 images a (re)scan of those
4700 files, which thus shouldn't do anything, took 1.2 seconds, with the
indexes added this only takes 0.4 seconds. Taking the same test on a
generated database containing 4M images + the actual 4700 images took 26
minutes for a rescan, and with the index existing also only takes 0.4
seconds.

* Add images.checksum unique constraint in code with fallback

Work around the issue where in some cases duplicate images (/checksums
on images) might exist. This as discussed in #1740 by creating the index
on startup and in case of an error logging the duplicates. This so the
users where this scenario exists can correct the database (by searching
on the logged checksum(s) and removing the duplicates) and after a
restart the unique index / constraint will still be created. In case
when creating the unique index fails a "normal" / non-unique index is
created as surrogate so the user will still get the performance benefit
(for example during scanning) without being forced to remove the
duplicates and restart beforehand. This surrogate is also automatically
cleaned up after the unique index is succesfully created.
2021-09-21 11:48:52 +10:00
SmallCoccinelle b7c229dc70
Set NORMAL sync on sqlite3 (#1684)
NORMAL sync is safe when using WAL journaliing.

It cuts the amount of sync calls to the disk, resulting in faster write
operation. On power loss, the database will perhaps lose some ongoing
commits, but that is all.

The expectation is that if the database lives on the same disk as the
stash, this could help performance quite a bit under heavier operation.
2021-09-21 11:38:56 +10:00
SmallCoccinelle 87709fd018
Errcheck phase 1 (#1715)
* Avoid redundant logging in migrations

Return the error and let the caller handle the logging of the error if
needed.

While here, defer m.Close() to the function boundary.

* Treat errors as values

Use %v rather than %s and pass the errors directly.

* Generate a wrapped error on stat-failure

* Log 3 unchecked errors

Rather than ignore errors, log them at
the WARNING log level.

The server has been functioning without these, so assume they are not at
the ERROR level.

* Propagate errors upward

Failure in path generation was ignored. Propagate the errors upward the
call stack, so it can be handled at the level of orchestration.

* Warn on errors

Log errors rather than quenching them.

Errors are logged at the Warn-level for now.

* Check error when creating test databases

Use the builtin log package and stop the program fatally on error.

* Add warnings to uncheck task errors

Focus on the task system in a single commit, logging unchecked
errors as warnings.

* Warn-on-error in API routes

Look through the API routes, and make sure errors are being logged if
they occur. Prefer the Warn-log-level because none of these has proven
to be fatal in the system up until now.

* Propagate error when adding Util API

* Propagate error on adding util API

* Return unhandled error

* JS log API: propagate and log errors

* JS Plugins: log GQL addition failures.

* Warn on failure to write to stdin

* Warn on failure to stop task

* Wrap viper.BindEnv

The current viper code only errors if no name is provided, so it should
never fail. Rewrite the code flow to factor through a panic-function.

This removes error warnings from this part of the code.

* Log errors in concurrency test

If we can't initialize the configuration, treat the test as a failure.

* Warn on errors in configuration code

* Plug an unchecked error in gallery zip walking

* Warn on screenshot serving failure

* Warn on encoder screenshot failure

* Warn on errors in path-handling code

* Undo the errcheck on configurations for now.

* Use one-line initializers where applicable

rather than using

  err := f()
  if err!= nil { ..

prefer the shorter

  if err := f(); err != nil { ..

If f() isn't too long of a name, or wraps a function with a body.
2021-09-21 09:34:25 +10:00
bnkai af6232ec97
Fix Query for Scene Markers (#1743) 2021-09-20 09:52:19 +10:00
liquid-flow 919249f851
Fix Scene Player CLS issue (#1739) 2021-09-19 11:31:52 +10:00
liquid-flow 13fda2ad85
Fix scene edit panel layout (#1737)
* Fix scene edit panel layout
2021-09-19 11:07:23 +10:00
gitgiggety 82e4ad4130
Execute Gallery.Create.Post plugin hook during scan (#1731)
* Execute Gallery.Create.Post plugin hook during scan

Fix issue where Gallery.Create.Post hook is not executed when a new
gallery is created during scan, when the gallery is created based on the
folder.

* Fix Gallery.Create.Post hook being invoked in transaction

Invoke the Gallery.Create.Post hook during zip scan after the
transaction has been committed. This is necessary to allow the plugin to
access the gallery (using GraphQL API). Otherwise the API obviously uses
a different database transaction which can't find the gallery as it
isn't committed yet.
2021-09-19 10:28:34 +10:00
gitgiggety b83ce29ac4
Scraper log improvements (#1741)
* Fix logs from scraper and plugins not being shown in UI

Using `logger.` in the logger package to write logs is "incorrect". This
as the package contains a variable named `logger` which contains the
logrus instance. So instead of the log line being handled by the custom
log implementation / wrapper which makes sure the lines are shown in the
UI as well, it's written to logrus directly meaning the wrapper is
skipped.

This "issue" is obviously triggered because in any other place
`logger.X` can be used and it will used the custom logger package /
wrapper which works fine.

* Add plugin / scraper name to logging output

Indicate which plugin / scraper wrote a log message by including its
name to the `[Scrape]` prefix.

* Add missing addLogItem call
2021-09-19 10:06:34 +10:00
WithoutPants 66f92c5dcc
Fix autotag tag alias (#1713)
* Add unit tests for tag alias
* Fix tag alias autotag
* Don't autotag non-path galleries
* Add studio alias tests
2021-09-17 09:23:56 +10:00
stg-annon d29699fa30
Support scraper logging to specific log levels (#1648)
* init scrapper log levels
* Refactor plugin logging

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2021-09-17 09:09:44 +10:00
WithoutPants 501ed7c2c2
Make hierarchical criterion depth input optional (#1733) 2021-09-16 20:41:07 +10:00
MartinWe13 e0c910d9e8
Adjustments German translation (#1730)
* Update de-DE.json

A few (first) adjustments to the German translation. Partly the words are chosen too long and translated not very technically.
2021-09-16 12:10:08 +10:00
gitgiggety f3119a6c38
Add AND, OR and NOT support to studio filter (#1726) 2021-09-16 12:09:23 +10:00
Still Hsu 23f852cd91
Add new zh-tw localizations & move non-legacy localization keys (#1693)
* Add new localizations & move non-legacy localization keys

Signed-off-by: Still Hsu <dev@stillu.cc>

* Fix sv-SE localization keys

Signed-off-by: Still Hsu <dev@stillu.cc>

* Fix duplicated key
* Add missing internationalisation

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2021-09-16 09:04:50 +10:00
gitgiggety 2274db16b7
Generate screenshot images for markers (#1604)
* Generate screenshot images for markers

In some scenarios it might not be possible to use the preview video or
image of markers, i.e. when only static images are supported like in
Kodi. So generate a static screenshot as well.

* Make generating animated and static image optional for markers
* Use screenshot for markers when preview type is set to static image
2021-09-15 12:27:05 +10:00
liquid-flow f5e4e7742e
[Bug Fix] Disable float-on-scroll JWPlayer feature on mobile (#1721)
* Disable video float on mobile
2021-09-15 10:13:45 +10:00
Perdition 3be23999ef
Update sv-SE.json (#1722)
Fixes a bunch of awkward sounding terms and other errors.
2021-09-14 23:21:59 +10:00
liquid-flow 612ecb72fc
[Bug Fix] Fix scene markers editor mobile UI (#1718)
* Fix mobile layout
2021-09-14 20:07:53 +10:00
gitgiggety b78060d361
Add rating sorting to galleries (#1720)
* Add rating sorting to galleries

Fixes: #1717
2021-09-14 18:11:12 +10:00
WithoutPants 1a3a2f1f83
Scrape scene by name (#1712)
* Support scrape scene by name in configs
* Initial scene querying
* Add to manual
2021-09-14 14:54:53 +10:00
gitgiggety 565064b441
Make IHierarchicalLabeledIdCriterion backwards compatible (#1716)
Add some form of backwards compatibility in the UI for
`IHierarchicalLabeledIdCriterion`. With this backwards compatibility
it's possible to recall saved filters which use the tags filter.
Otherwise stuff would blow up because the saved filter has a different
structure than what the `IHierarchicalLabeledIdCriterion` expects.
2021-09-11 10:01:57 +10:00
WithoutPants 13a289a4a8
Fix studio scene count sort (#1714) 2021-09-09 19:44:02 +10:00
gitgiggety 04e5ac9c2f
Studio aliases (#1660)
* Add migration to create studio aliases table
* Refactor studioQueryBuilder.Query to use filterBuilder
* Expand GraphQL API with aliases support for studio
* Add aliases support for studios to the UI
* List aliases in details panel
* Allow editing aliases in edit panel
* Add 'aliases' filter when searching
* Find studios by alias in filter / select
* Add auto-tagging based on studio aliases
* Support studio aliases for filename parsing
* Support importing and exporting of studio aliases
* Search for studio alias as well during scraping
2021-09-09 18:13:42 +10:00
gitgiggety c91ffe1e58
Tag hierarchy (#1519)
* Add migration script for tag relations table
* Expand hierarchical filter features

Expand the features of the hierarchical multi input filter with support
for using a relations table, which only has parent_id and child_id
columns, and support adding an additional intermediate table to join on,
for example for scenes and tags which are linked by the scenes_tags
table as well.

* Add hierarchical filtering for tags
* Add hierarchical tags support to scene markers

Refactor filtering of scene markers to filterBuilder and in the process
add support for hierarchical tags as well.

* List parent and child tags on tag details page
* Support setting parent and child tags

Add support for setting parent and child tags during tag creation and
tag updates.

* Validate no loops are created in tags hierarchy
* Update tag merging to support tag hierarcy
* Add unit tests for tags.EnsureUniqueHierarchy
* Fix applying recursive to with clause

The SQL `RECURSIVE` of a `WITH` clause only needs to be applied once,
imediately after the `WITH`. So this fixes the query building to do just
that, automatically applying the `RECURSIVE` keyword when any added with
clause is added as recursive.

* Rename hierarchical root id column
* Rewrite hierarchical filtering for performance

Completely rewrite the hierarchical filtering to optimize for
performance. Doing the recursive query in combination with a complex
query seems to break SQLite optimizing some things which means that the
recursive part might be 2,5 second slower than adding a static
`VALUES()` list. This is mostly noticable in case of the tag hierarchy
where setting an exclusion with any depth (or depth: all) being applied
has this performance impact of 2,5 second. "Include" also suffered this
issue, but some rewritten query by joining in the *_tags table in one
pass and applying a `WHERE x IS NOT NULL` filter did seem to optimize
that case. But that optimization isn't applied to the `IS NULL` filter
of "exclude". Running a simple query beforehand to get all (recursive)
items and then applying them to the query doesn't have this performance
penalty.

* Remove UI references to child studios and tags
* Add parents to tag export
* Support importing of parent relationship for tags
* Assign stable ids to parent / child badges
* Silence Apollo warning on parents/children fields on tags

Silence warning triggered by Apollo GraphQL by explicitly instructing it
to use the incoming parents/children values. By default it already does
this, but it triggers a warning as it might be unintended that it uses
the incoming values (instead of for example merging both arrays).
Setting merge to false still applies the same behaviour (use only
incoming values) but silences the warning as it's explicitly configured
to work like this.

* Rework detecting unique tag hierarchy

Completely rework the unique tag hierarchy to detect invalid hierarchies
for which a tag is "added in the middle". So when there are tags A <- B
and A <- C, you could previously edit tag B and add tag C as a sub tag
without it being noticed as parent A being applied twice (to tag C).
While afterwards saving tag C would fail as tag A was applied as parent
twice. The updated code correctly detects this scenario as well.

Furthermore the error messaging has been reworked a bit and the message
now mentions both the direct parent / sub tag as well as the tag which
would results in the error. So in aboves example it would now show the
message that tag C can't be applied because tag A already is a parent.

* Update relations on cached tags when needed

Update the relations on cached tags when a tag is created / updated /
deleted so these always reflect the correct state. Otherwise (re)opening
a tag might still show the old relations untill the page is fully
reloaded or the list is navigated. But this obviously is strange when
you for example have tag A, create or update tag B to have a relation to
tag A, and from tags B page click through to tag A and it doesn't show
that it is linked to tag B.
2021-09-09 14:58:43 +10:00
SmallCoccinelle 82a41e17c7
Avoid wrapping strings.Replace in Contains (#1710)
The strings.Replace function counts the number of replacements. If 0,
the original string is returned. Hence, there is no need to check if a
replacement will happen before doing the work.
2021-09-09 14:10:39 +10:00
SmallCoccinelle 4b00d24248
Remove unused (#1709)
* Remove stuff which isn't being used

Some fields, functions and structs aren't in use by the project. Remove
them for janitorial reasons.

* Remove more unused code

All of these functions are currently not in use. Clean up the code by
removal, since the version control has the code if need be.

* Remove unused functions

There's a large set of unused functions and variables in the code base.
Remove these, so it clearer what code to support going forward.

Dead code has been eliminated.

Where applicable, comment const-sections in tests, so reserved
identifiers are still known.

* Fix use-def of tsURL

The first def of tsURL doesn't matter because there's no use before
we hit the 2nd def.

* Remove dead code assignment

Setting logFile = "" is effectively dead code, because there's no use
of it later.

* Comment out found

The variable 'found' is dead in the function (because no post-process
action is following it). Comment it for now.

* Comment dead code in tests

These might provide hints as to what isn't covered at the moment.

* Dead code removal

In the case of constants where iota is involved, move the iota so it
matches the current key values.

This avoids problems with persistently stored key IDs.
2021-09-09 14:10:08 +10:00
kermieisinthehouse 265d5f4c70
Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646)
* Bump Go to 1.17, refactor build/x86_64 Dockerfile to make better use of multi-stage
* Bump to 1.17 from 1.16
* Bump packr version, provide needed legacy env var
* Add apple silicon support, fix macos build chain
* Update unused travis ci
2021-09-08 15:30:15 +10:00
SmallCoccinelle 4545da9af0
Avoid redundant break statements (#1705)
In Go, a switch-case automatically breaks on end. This makes
the break statement redundant.
2021-09-08 11:23:21 +10:00
SmallCoccinelle e7f6cb22b7
Error strings noncapitalized (#1704)
* Fix error string capitalization

Error strings often follow another string. Hence, they should not be
capitalized, unless referencing a name.

* Uncapitalize more error strings

While here, use %v on the error directly, which makes it easier to wrap
the error later with %w if need be.

* Uncapitalize more error strings

While here, rename Url to URL as a nitpick.
2021-09-08 11:23:10 +10:00
SmallCoccinelle d2a0a8fe4c
Correct error propagation (#1703)
Rename an inner error to imageErr. This avoids a shadowing of an error
in the following lines which aren't returned otherwise.
2021-09-08 11:22:56 +10:00
Alpaca Serious b482fbc796
Swedish Translation (#1691)
* Added Swedish translation
* Update SettingsInterfacePanel.tsx
* Update index.ts
* Update sv-SE.json
2021-09-08 11:08:07 +10:00
SmallCoccinelle a3f38d8edf
When stopping, close the database (#1686)
* When stopping, close the database

This patch is likely to cause errornous behavior in the application.
This is due to the fact that the application doesn't gracefully shut
down, but is forcefully terminated.

However, the purpose is to uncover what needs to be done, to make
it a more graceful shutdown.
2021-09-07 14:28:40 +10:00
fnoopv 651d2e6373
Add missing translation (#1701) 2021-09-07 13:30:59 +10:00
SmallCoccinelle b76283df08
Fix data race in progress_test (#1696)
The call to p.ExecuteTask happens in a separate go-routine. It writes,
under m.mutex, into the job's details. However, the test goroutine
itself reads j.Details which is a read race.

Protect the reads in the test by the lock.

This makes `package job` pass `go test -race`
2021-09-07 13:30:26 +10:00
SmallCoccinelle 489db34db2
Remove assignments to _ (#1685)
It's a no-op if we are not using it, so it can be safely removed.
2021-09-07 13:18:32 +10:00
gitgiggety b2b05fb332
Add Movie option to Scene bulk edit (#1676)
* Add Movie option to Scene bulk edit
2021-09-07 12:44:18 +10:00
gitgiggety 7a468413da
Add movies tab to Studios and Performers page (#1675)
* Add movies tab to Studios page
* Add performers filter to movies
* Add movies tab to performers page
2021-09-07 12:16:33 +10:00
WithoutPants 4625e1f955
Unify scrape refactor (#1630)
* Unify scraped types
* Make name fields optional
* Unify single scrape queries
* Change UI to use new interfaces
* Add multi scrape interfaces
* Use images instead of image
2021-09-07 11:54:22 +10:00
WithoutPants 04e146f290
Merge pull request #1700 from stashapp/master
Merge master to develop for version tag
2021-09-06 17:03:37 +10:00
WithoutPants ab10cf8251
Merge pull request #1697 from stashapp/develop
Merge develop to master for 0.9
2021-09-06 12:47:07 +10:00
Tweeticoats a73c99a61d
Update docker file to add mechanicalsoup python library (#1688)
Add a new python library mechanicalsoup to the docker container.
There is a pending pull request in the Community scrapers for the Ifeelmyself that uses this library so it might be worth including it in the container.
This should add ~100k to the size of the container.
2021-08-31 20:14:39 +10:00
WithoutPants 709d7ce1cc
Load TLS config files from config path before stash home (#1678)
* Load tls files from config or home directory
* Update README
* Require both ssl files if either present
2021-08-31 19:37:45 +10:00
gitgiggety 1774a3600c
Fix Performers Is Missing: stash ID filter (#1681)
* Fix Performers Is Missing: stash ID filter.

Fixes #1679
2021-08-30 11:46:41 +10:00
FleetingOrchard 50cb6a9c79
Add duration statistics to stats page (#1626) 2021-08-26 13:37:08 +10:00
UnluckyChemical765 45a9aabdaf
Add script offset / delay to Handy support. (#1573)
* Add script offset / delay to Handy support.

Further work on  #1376.

Offsets are added to the current video position, so a positive value leads to earlier motion.  (The most common setting.)

This is needed because most script times have a consistent delay when compared to the video. (Delay from the API calls to the server should be handled by the server offset calculation.)

* Rename scriptOffset to funscriptOffset
* Correct localisation keys

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2021-08-26 11:50:02 +10:00
gitgiggety 50217f6318
Rebuild image edit using formik (#1669)
* Rebuild image edit using formik
* Prompt on page leave when changes are not saved
* Only enables save when changes are made
* Wrap in <Form onSubmit> (not sure if this does anything)
2021-08-26 11:24:49 +10:00