]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix boundary conditions trimming sqlite3 storage cache
authorMatt Joiner <anacrolix@gmail.com>
Mon, 18 Jan 2021 03:40:48 +0000 (14:40 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 18 Jan 2021 03:48:30 +0000 (14:48 +1100)
storage/sqlite/sqlite-storage.go

index 22b4b8fd071f91e573ca06938da45a4bcfddc2ed..b046d0d3fddd814424a8cb7df82aef8e1b99d3c5 100644 (file)
@@ -92,16 +92,16 @@ with recursive excess (
                        length(cast(data as blob))
                from blob order by last_used, rowid limit 1
        )
-       where usage_with >= (select value from setting where name='capacity')
+       where usage_with > (select value from setting where name='capacity')
        union all
        select 
-               usage_with-data_length,
+               usage_with-data_length as new_usage_with,
                blob.last_used,
                blob.rowid,
                length(cast(data as blob))
        from excess join blob
        on blob.rowid=(select rowid from blob where (last_used, rowid) > (excess.last_used, blob_rowid))
-       where usage_with >= (select value from setting where name='capacity')
+       where new_usage_with > (select value from setting where name='capacity')
 )
 select * from excess;