exclude sd blobs from calculation and make them be picked last on removal

This commit is contained in:
Victor Shyba 2022-03-21 04:26:27 -03:00
parent ad489ed606
commit 34bd9e5cb4

View file

@ -449,7 +449,8 @@ class SQLiteStorage(SQLiteMixin):
return await self.db.execute_fetchall( return await self.db.execute_fetchall(
"select blob.blob_hash, blob.blob_length, blob.added_on " "select blob.blob_hash, blob.blob_length, blob.added_on "
"from blob left join stream_blob using (blob_hash) " "from blob left join stream_blob using (blob_hash) "
"where stream_blob.stream_hash is null and blob.is_mine=? order by blob.added_on asc", "where stream_blob.stream_hash is null and blob.is_mine=?"
"order by blob.blob_length desc, blob.added_on asc",
(is_mine,) (is_mine,)
) )
@ -479,7 +480,7 @@ class SQLiteStorage(SQLiteMixin):
coalesce(sum(case when coalesce(sum(case when
is_mine=1 is_mine=1
then blob_length else 0 end), 0) as private_storage then blob_length else 0 end), 0) as private_storage
from blob left join stream_blob using (blob_hash) from blob left join stream_blob using (blob_hash) where blob_hash not in (select sd_hash from stream)
""") """)
return { return {
'network_storage': network_size, 'network_storage': network_size,