[feature] Clean up/uncache remote media (#407)

* Add whereNotEmptyAndNotNull

* Add GetRemoteOlderThanDays

* Add GetRemoteOlderThanDays

* Add PruneRemote to Manager interface

* Start implementing PruneRemote

* add new attachment + status to tests

* fix up and test GetRemoteOlderThan

* fix bad import

* PruneRemote: return number pruned

* add Cached column to mediaattachment

* update + test pruneRemote

* update mediaTest

* use Cached column

* upstep bun to latest version

* embed structs in mediaAttachment

* migrate mediaAttachment to new format

* don't default cached to true

* select only remote media

* update db dependencies

* step bun back to last working version

* update pruneRemote to use Cached field

* fix storage path of test attachments

* add recache logic to manager

* fix trimmed aspect ratio

* test prune and recache

* return errwithcode

* tidy up different paths for emoji vs attachment

* fix incorrect thumbnail type being stored

* expose TransportController to media processor

* implement tee-ing recached content

* add thoughts of dog to test fedi attachments

* test get remote files

* add comment on PruneRemote

* add postData cleanup to recache

* test thumbnail fetching

* add incredible diagram

* go mod tidy

* buffer pipes for recache streaming

* test for client stops reading after 1kb

* add media-remote-cache-days to config

* add cron package

* wrap logrus so it's available to cron

* start and stop cron jobs gracefully
This commit is contained in:
tobi 2022-03-07 11:08:26 +01:00 committed by GitHub
commit 07727753b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
424 changed files with 637100 additions and 176498 deletions

View file

@ -1,4 +1,4 @@
// Code generated by 'ccgo -D__environ=environ -export-externs X -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -nostdinc -nostdlib -o ../musl_windows_386.go -pkgname libc -static-locals-prefix _s -Iarch/i386 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c src/ctype/isalnum.c src/ctype/isalpha.c src/ctype/isdigit.c src/ctype/islower.c src/ctype/isprint.c src/ctype/isspace.c src/ctype/isxdigit.c src/env/putenv.c src/env/setenv.c src/env/unsetenv.c src/multibyte/wcrtomb.c src/multibyte/wcsrtombs.c src/multibyte/wcstombs.c src/string/strchrnul.c src/string/strdup.c', DO NOT EDIT.
// Code generated by 'ccgo -D__environ=environ -export-externs X -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -nostdinc -nostdlib -o ../musl_windows_386.go -pkgname libc -static-locals-prefix _s -Iarch\i386 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c src/ctype/isalnum.c src/ctype/isalpha.c src/ctype/isdigit.c src/ctype/islower.c src/ctype/isprint.c src/ctype/isspace.c src/ctype/isxdigit.c src/env/putenv.c src/env/setenv.c src/env/unsetenv.c src/multibyte/wcrtomb.c src/multibyte/wcsrtombs.c src/multibyte/wcstombs.c src/stdlib/bsearch.c src/string/strchrnul.c src/string/strdup.c', DO NOT EDIT.
package libc
@ -863,32 +863,32 @@ type mode_t = uint32 /* alltypes.h:175:18 */
type syscall_arg_t = int32 /* syscall.h:22:14 */
func a_cas(tls *TLS, p uintptr, t int32, s int32) int32 { /* atomic_arch.h:2:19: */
panic(`arch/i386/atomic_arch.h:4:2: assembler statements not supported`)
panic(`arch\i386\atomic_arch.h:4:2: assembler statements not supported`)
return t
}
func a_and(tls *TLS, p uintptr, v int32) { /* atomic_arch.h:29:20: */
panic(`arch/i386/atomic_arch.h:31:2: assembler statements not supported`)
panic(`arch\i386\atomic_arch.h:31:2: assembler statements not supported`)
}
func a_or(tls *TLS, p uintptr, v int32) { /* atomic_arch.h:37:20: */
panic(`arch/i386/atomic_arch.h:39:2: assembler statements not supported`)
panic(`arch\i386\atomic_arch.h:39:2: assembler statements not supported`)
}
func a_ctz_64(tls *TLS, x uint64_t) int32 { /* atomic_arch.h:87:19: */
var r int32
panic(`arch/i386/atomic_arch.h:90:2: assembler statements not supported`)
panic(`arch\i386\atomic_arch.h:90:2: assembler statements not supported`)
return r
}
func a_ctz_32(tls *TLS, x uint32_t) int32 { /* atomic_arch.h:96:19: */
var r int32
panic(`arch/i386/atomic_arch.h:99:2: assembler statements not supported`)
panic(`arch\i386\atomic_arch.h:99:2: assembler statements not supported`)
return r
}
func a_clz_32(tls *TLS, x uint32_t) int32 { /* atomic_arch.h:104:19: */
panic(`arch/i386/atomic_arch.h:106:2: assembler statements not supported`)
panic(`arch\i386\atomic_arch.h:106:2: assembler statements not supported`)
return int32(x)
}
@ -917,7 +917,7 @@ type __timer = struct {
func __pthread_self(tls *TLS) uintptr { /* pthread_arch.h:1:30: */
var self uintptr
panic(`arch/i386/pthread_arch.h:4:2: assembler statements not supported`)
panic(`arch\i386\pthread_arch.h:4:2: assembler statements not supported`)
return self
}
@ -1039,6 +1039,26 @@ func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c
return Xwcsrtombs(tls, s, bp, n, uintptr(0))
}
func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
var try uintptr
var sign int32
for nel > size_t(0) {
try = base + uintptr(width*(nel/size_t(2)))
sign = (*struct {
f func(*TLS, uintptr, uintptr) int32
})(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
if sign < 0 {
nel = nel / size_t(2)
} else if sign > 0 {
base = try + uintptr(width)
nel = nel - (nel/size_t(2) + size_t(1))
} else {
return try
}
}
return uintptr(0)
}
// Support signed or unsigned plain-char
// Implementation choices...