forked from LBRYCommunity/lbry-sdk
return number of files deleted
This commit is contained in:
parent
2cd5d75a2e
commit
3433c9e708
1 changed files with 3 additions and 3 deletions
|
@ -28,7 +28,7 @@ class DiskSpaceManager:
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if not self.config.blob_storage_limit:
|
if not self.config.blob_storage_limit:
|
||||||
return False
|
return 0
|
||||||
used = 0
|
used = 0
|
||||||
files = []
|
files = []
|
||||||
data_dir = os.path.join(self.config.data_dir, 'blobfiles')
|
data_dir = os.path.join(self.config.data_dir, 'blobfiles')
|
||||||
|
@ -39,13 +39,13 @@ class DiskSpaceManager:
|
||||||
files.append((file_stats.st_mtime, file_stats.st_size, file.path))
|
files.append((file_stats.st_mtime, file_stats.st_size, file.path))
|
||||||
files.sort()
|
files.sort()
|
||||||
available = (self.config.blob_storage_limit*1024*1024) - used
|
available = (self.config.blob_storage_limit*1024*1024) - used
|
||||||
cleaned = False
|
cleaned = 0
|
||||||
for _, file_size, file in files:
|
for _, file_size, file in files:
|
||||||
available += file_size
|
available += file_size
|
||||||
if available > 0:
|
if available > 0:
|
||||||
break
|
break
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
cleaned = True
|
cleaned += 1
|
||||||
return cleaned
|
return cleaned
|
||||||
|
|
||||||
async def cleaning_loop(self):
|
async def cleaning_loop(self):
|
||||||
|
|
Loading…
Reference in a new issue