Commit Graph

34 Commits

Author SHA1 Message Date
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
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 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
WithoutPants 0e01374537
Job queueing (#1379) 2021-05-24 14:24:18 +10:00
WithoutPants f6ffda7504
Setup and migration UI refactor (#1190)
* Make config instance-based
* Remove config dependency in paths
* Refactor config init
* Allow startup without database
* Get system status at UI initialise
* Add setup wizard
* Cache and Metadata optional. Database mandatory
* Handle metadata not set during full import/export
* Add links
* Remove config check middleware
* Stash not mandatory
* Panic on missing mandatory config fields
* Redirect setup to main page if setup not required
* Add migration UI
* Remove unused stuff
* Move UI initialisation into App
* Don't create metadata paths on RefreshConfig
* Add folder selector for generated in setup
* Env variable to set and create config file.
Make docker images use a fixed config file.
* Set config file during setup
2021-04-12 09:31:33 +10:00
WithoutPants 73a8bad1bc
Add missing tag writer for performer importer (#1213) 2021-03-18 21:45:31 +11:00
InfiniteTF 6114caa938
Fix import file copying (#1085) 2021-02-01 08:15:10 +11:00
InfiniteTF 89fcd6d775
Make file upload limits configurable (#1079) 2021-01-29 20:27:02 +11:00
WithoutPants 1e04deb3d4
Data layer restructuring (#997)
* Move query builders to sqlite package
* Add transaction system
* Wrap model resolvers in transaction
* Add error return value for StringSliceToIntSlice
* Update/refactor mutation resolvers
* Convert query builders
* Remove unused join types
* Add stash id unit tests
* Use WAL journal mode
2021-01-18 12:23:20 +11:00
WithoutPants aca2c7c5f4
Images section (#813)
* Add new configuration options
* Refactor scan/clean
* Schema changes
* Add details to galleries
* Remove redundant code
* Refine thumbnail generation
* Gallery overhaul
* Don't allow modifying zip gallery images
* Show gallery card overlays
* Hide zoom slider when not in grid mode
2020-10-13 10:12:46 +11:00
WithoutPants 8866670e53
Add partial import functionality (#812) 2020-09-20 18:36:02 +10:00
WithoutPants 03d4826c85
Selective export (#770) 2020-09-15 17:28:53 +10:00
WithoutPants a39666467e
Fix import performers/movies/studios with no image (#732) 2020-08-14 09:40:25 +10:00
WithoutPants 5992ff8706
Add oshash support (#667) 2020-08-06 11:21:14 +10:00
WithoutPants 244ae54f3f
Add grid view, image to tag (#641)
* Add grid view for tags
* Add tag page
* Import/export tags
* Add tag name uniqueness checks
* Fix styling on missing marker previews
* Add trace loglevel
* Add SQL trace
* Add filter options for tags
* Add tag sort by options
* Add tag page keyboard shortcuts
2020-07-07 10:35:43 +10:00
WithoutPants 7a74658a73
Move image blobs into separate tables (#618)
* Scene cover fallback to database
* Fix panic if studio not found
* Fix movie studio not being imported/exported
2020-06-23 09:19:19 +10:00
WithoutPants 96e6e16507
Parent studios (#595)
* Refactor getMultiCriterionClause
Co-authored-by: Anon247 <61889302+Anon247@users.noreply.github.com>
2020-06-15 21:34:39 +10:00
bnkai ccd75731b7
Change scrape matching (studio, movies, tag, performers) to case insensitive (#556)
* Change scrape matching (studio, movies, tag, performers) to case insensitive
* * fix collate order
* * make filename parser findbyname calls case insensitive
* * add unit testing for Tags GetFindbyName/s
2020-05-24 16:19:22 +10:00
WithoutPants ba09bfa64a
Include scene o-counter in import/export (#488)
* Include o-counter in import/export
* Fix scene card o-counter display
2020-04-23 09:14:58 +10:00
WithoutPants eee7adfb85
Add Studio to movie and fix movie schema (#458)
* Add movie migration
* Update server and UI code for type changes
* Add studio to movies
* Movie blobs to end
* Document movie duration
* Add filtering on movie studio
2020-04-22 11:22:14 +10:00
bnkai d5617307f1
Add detection of container/video_codec/audio_codec compatibility for live file streaming or transcoding (#384)
* add forceMKV, forceHEVC config options
* drop audio stream instead of trying to transcode for ffmpeg unsupported/unknown audio codecs
2020-04-10 08:38:34 +10:00
hiddenpants255 494b794228
Add gender support for performer (#371)
Co-authored-by: HiddenPants255 <>
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2020-04-01 09:36:38 +11:00
caustico 5fb8bbf768
Movies Section (#338)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2020-03-10 14:28:15 +11:00
Stash Dev f8aa0433a3 Fix scene covers not importing correctly 2020-01-06 15:18:06 -08:00
Stash Dev 653406efd1 Added support for import / export of scene cover images 2019-12-31 14:38:49 -08:00
WithoutPants 6dcb270471 Close database after migrating. Add reset errors (#215) 2019-11-17 16:39:33 -05:00
WithoutPants 9e8d7bb26f Fix panic on import with existing scene (#205) 2019-11-15 16:34:00 -05:00
WithoutPants 7f276cb331 Fix checksum for import performer/studio 2019-08-22 12:43:24 +10:00
Stash Dev 4b037e1040 Dependency updates 2019-05-27 12:34:26 -07:00
Stash Dev d6eb2c2d8e Scenes with a marker missing a primary tag fails to load
Fixes #42
2019-04-20 10:32:01 -07:00
Stash Dev 4f7266f0ed Added created / updated timestamp to exported JSON 2019-03-27 14:00:06 -07:00
Stash Dev dd22d88d07 Config Tweaks
Using viper for config management.  Added configuration endpoint.
2019-03-23 10:06:37 -07:00
Stash Dev b70d5f33d2 Improved date handling 2019-03-04 17:14:52 -08:00
Stash Dev b488c1ed7d Reorg 2019-02-14 15:42:52 -08:00