def cleanup_unused_files(quiet=False):
 from sentry.models import File, FileBlob, FileBlobIndex
 if quiet:
  from sentry.utils.query import RangeQuerySetWrapper
 else:
  from sentry.utils.query import RangeQuerySetWrapperWithProgressBar as RangeQuerySetWrapper
 cutoff = (timezone.now() - timedelta(days=1))
 queryset = FileBlob.objects.filter(timestamp__lte=cutoff)
 for blob in RangeQuerySetWrapper(queryset):
  if FileBlobIndex.objects.filter(blob=blob).exists():
   continue
  if File.objects.filter(blob=blob).exists():
   continue
  blob.delete()

def cleanup_unused_files ( quiet = False ) : from sentry . models import File , FileBlob , FileBlobIndex if quiet : from sentry . utils . query import RangeQuerySetWrapper else : from sentry . utils . query import RangeQuerySetWrapperWithProgressBar as RangeQuerySetWrapper cutoff = ( timezone . now ( ) - timedelta ( days = 1 ) ) queryset = FileBlob . objects . filter ( timestamp__lte = cutoff ) for blob in RangeQuerySetWrapper ( queryset ) : if FileBlobIndex . objects . filter ( blob = blob ) . exists ( ) : continue if File . objects . filter ( blob = blob ) . exists ( ) : continue blob . delete ( )
remove fileblobs if they are no longer referenced by any file .