From 34bd9e5cb408d1ce78ac4f7f47d7c4c7f09c6a66 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 21 Mar 2022 04:26:27 -0300 Subject: [PATCH] exclude sd blobs from calculation and make them be picked last on removal --- lbry/extras/daemon/storage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lbry/extras/daemon/storage.py b/lbry/extras/daemon/storage.py index e5c9ec67c..c53f81a66 100644 --- a/lbry/extras/daemon/storage.py +++ b/lbry/extras/daemon/storage.py @@ -449,7 +449,8 @@ class SQLiteStorage(SQLiteMixin): return await self.db.execute_fetchall( "select blob.blob_hash, blob.blob_length, blob.added_on " "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,) ) @@ -479,7 +480,7 @@ class SQLiteStorage(SQLiteMixin): coalesce(sum(case when is_mine=1 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 { 'network_storage': network_size,