diff options
author | 2022-12-12 11:22:19 +0000 | |
---|---|---|
committer | 2022-12-12 12:22:19 +0100 | |
commit | 58c87bdd7f37e80a57c4802e95eb6c572ccffed4 (patch) | |
tree | ecfa90c1249adbd02b386f624b9dbf3c405cafd6 /internal/media/processingmedia.go | |
parent | [chore]: Bump golang.org/x/image from 0.1.0 to 0.2.0 (#1252) (diff) | |
download | gotosocial-58c87bdd7f37e80a57c4802e95eb6c572ccffed4.tar.xz |
[feature] allow uncaching of other media types (#1234)
* simplify pruneRemote, remove unncecessary media trace logging, update RemoteOlderThan() to include headers/avis
Signed-off-by: kim <grufwub@gmail.com>
* cleanup pruneallmeta, add remote header to pruneremote tests
Signed-off-by: kim <grufwub@gmail.com>
* fix olderthan duration additions
Signed-off-by: kim <grufwub@gmail.com>
* fix broken test now that test model header changed
Signed-off-by: kim <grufwub@gmail.com>
* instead use new remote test account for new header model
Signed-off-by: kim <grufwub@gmail.com>
* use newer generated ULID for remote_account_3 to ensure it is sorted last
Signed-off-by: kim <grufwub@gmail.com>
* reorganize serialized keys to match expected test account model order
Signed-off-by: kim <grufwub@gmail.com>
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/media/processingmedia.go')
-rw-r--r-- | internal/media/processingmedia.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index 1fd9423f5..94c8f9a7a 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -81,10 +81,8 @@ func (p *ProcessingMedia) AttachmentID() string { // LoadAttachment blocks until the thumbnail and fullsize content // has been processed, and then returns the completed attachment. func (p *ProcessingMedia) LoadAttachment(ctx context.Context) (*gtsmodel.MediaAttachment, error) { - log.Tracef("LoadAttachment: getting lock for attachment %s", p.attachment.URL) p.mu.Lock() defer p.mu.Unlock() - log.Tracef("LoadAttachment: got lock for attachment %s", p.attachment.URL) if err := p.store(ctx); err != nil { return nil, err @@ -98,23 +96,24 @@ func (p *ProcessingMedia) LoadAttachment(ctx context.Context) (*gtsmodel.MediaAt return nil, err } - // store the result in the database before returning it if !p.insertedInDB { if p.recache { - // if it's a recache we should only need to update + // This is an existing media attachment we're recaching, so only need to update it if err := p.database.UpdateByID(ctx, p.attachment, p.attachment.ID); err != nil { return nil, err } } else { - // otherwise we need to really PUT it + // This is a new media attachment we're caching for first time if err := p.database.Put(ctx, p.attachment); err != nil { return nil, err } } + + // Mark this as stored in DB p.insertedInDB = true } - log.Tracef("LoadAttachment: finished, returning attachment %s", p.attachment.URL) + log.Tracef("finished loading attachment %s", p.attachment.URL) return p.attachment, nil } @@ -180,7 +179,7 @@ func (p *ProcessingMedia) loadThumb(ctx context.Context) error { // we're done processing the thumbnail! atomic.StoreInt32(&p.thumbState, int32(complete)) - log.Tracef("loadThumb: finished processing thumbnail for attachment %s", p.attachment.URL) + log.Tracef("finished processing thumbnail for attachment %s", p.attachment.URL) fallthrough case complete: return nil @@ -241,7 +240,7 @@ func (p *ProcessingMedia) loadFullSize(ctx context.Context) error { // we're done processing the full-size image atomic.StoreInt32(&p.fullSizeState, int32(complete)) - log.Tracef("loadFullSize: finished processing full size image for attachment %s", p.attachment.URL) + log.Tracef("finished processing full size image for attachment %s", p.attachment.URL) fallthrough case complete: return nil @@ -362,7 +361,7 @@ func (p *ProcessingMedia) store(ctx context.Context) error { p.attachment.File.FileSize = int(fileSize) p.read = true - log.Tracef("store: finished storing initial data for attachment %s", p.attachment.URL) + log.Tracef("finished storing initial data for attachment %s", p.attachment.URL) return nil } |