Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support a minModTime input on metadata scans. (stashapp#1951)
* Support a maxAge input on metadata scans. Extend the GraphQL world with a Duration scalar. It is parsed as a typical Go duration, i.e., "4h" is 4 hours. Alternatively, one can pass an integer which is interpreted as seconds. Extend Mutation.metadataScan(input: $input) to support a new optional value, maxAge. If set, the scanner will exit early if the file it is looking at has an mtime older than the cutOff point generated by now() - maxAge This speeds up scanning in the case where the user knows how old the changes on disk are, by exiting the scan early if that is the case. * Change maxAge into minModTime Introduce a `Timestamp` scalar, so we have a scalar we control. Let it accept three formats: * RFC3339Nano * @unix where UNIX is a unix-timestamp: seconds after 01-01-1970 * '<4h': a timestamp relative to the current server time This scalar parses to a time.Time. Use MinModTime in the scanner to filter out a large number of scan analyzes by exiting the scan operation early. * Heed the linter, perform errcheck * Rename test vars for consistency. * Code review: move minModTime into queuefiles * Remove the ability to input Unix timestamps Test failures on the CI-system explains why this is undesirable. It is not clear what timezone one is operating in when entering a unix timestamp. We could go with UTC, but it is so much easier to require an RFC3339 timestamp, which avoids this problem entirely. * Move the minModTime field into filters Create a new filter input object for metadata scans, and push the minModTime field in there. If we come up with new filters, they can be added to that input object rather than cluttering the main input object. * Use utils.ParseDateStringAsTime Replace time.Parse with utils.ParseDateStringAsTime While here, add some more test cases for that parser.
- Loading branch information