Move get used optional file size to separate function
This commit is contained in:
parent
a715650af6
commit
d7b6c54b08
1 changed files with 7 additions and 3 deletions
|
@ -343,6 +343,12 @@ class ContentDbPlugin(object):
|
|||
limit_bytes = float(re.sub("[^0-9.]", "", config.optional_limit)) * 1024 * 1024 * 1024
|
||||
return limit_bytes
|
||||
|
||||
def getOptionalUsedBytes(self):
|
||||
size = self.execute("SELECT SUM(size) FROM file_optional WHERE is_downloaded = 1 AND is_pinned = 0").fetchone()[0]
|
||||
if not size:
|
||||
size = 0
|
||||
return size
|
||||
|
||||
def getOptionalNeedDelete(self, size):
|
||||
if config.optional_limit.endswith("%"):
|
||||
limit_percent = float(re.sub("[^0-9.]", "", config.optional_limit))
|
||||
|
@ -359,9 +365,7 @@ class ContentDbPlugin(object):
|
|||
self.log.debug("Invalid limit for optional files: %s" % limit)
|
||||
return False
|
||||
|
||||
size = self.execute("SELECT SUM(size) FROM file_optional WHERE is_downloaded = 1 AND is_pinned = 0").fetchone()[0]
|
||||
if not size:
|
||||
size = 0
|
||||
size = self.getOptionalUsedBytes()
|
||||
|
||||
need_delete = self.getOptionalNeedDelete(size)
|
||||
|
||||
|
|
Loading…
Reference in a new issue