mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user