fix black
This commit is contained in:
@@ -43,9 +43,7 @@ def db_update(dbdict, libid, **kwargs):
|
|||||||
if libid not in dbdict:
|
if libid not in dbdict:
|
||||||
dbdict[libid] = {}
|
dbdict[libid] = {}
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
logging.debug(
|
logging.debug("Updating '%s' of library '%s' in in-memory cache dictionary", key, libid)
|
||||||
"Updating '%s' of library '%s' in in-memory cache dictionary", key, libid
|
|
||||||
)
|
|
||||||
dbdict[libid][key] = value
|
dbdict[libid][key] = value
|
||||||
|
|
||||||
db_write(dbdict)
|
db_write(dbdict)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def convert_bytes(size):
|
|||||||
"""Convert bytes to KB, MB etc depending on size"""
|
"""Convert bytes to KB, MB etc depending on size"""
|
||||||
power = 1024
|
power = 1024
|
||||||
level = 0
|
level = 0
|
||||||
labels = {0 : 'B', 1: 'KB', 2: 'MB', 3: 'GB', 4: 'TB'}
|
labels = {0: "B", 1: "KB", 2: "MB", 3: "GB", 4: "TB"}
|
||||||
while size > power:
|
while size > power:
|
||||||
size /= power
|
size /= power
|
||||||
level += 1
|
level += 1
|
||||||
|
|||||||
@@ -121,16 +121,12 @@ def main():
|
|||||||
libid = lib["id"]
|
libid = lib["id"]
|
||||||
# Set resync interval if there is a lib-specific setting. Otherwise default
|
# Set resync interval if there is a lib-specific setting. Otherwise default
|
||||||
libresyncinterval = (
|
libresyncinterval = (
|
||||||
lib["resync_interval_days"]
|
lib["resync_interval_days"] if "resync_interval_days" in lib else resyncinterval
|
||||||
if "resync_interval_days" in lib
|
|
||||||
else resyncinterval
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if last sync of library is older than resync_interval_days
|
# Check if last sync of library is older than resync_interval_days
|
||||||
if sf_lastsync_old_enough(cache, libid, args.force, libresyncinterval):
|
if sf_lastsync_old_enough(cache, libid, args.force, libresyncinterval):
|
||||||
logging.info(
|
logging.info("Starting to re-sync library %s (%s) to %s", libname, libid, libdir)
|
||||||
"Starting to re-sync library %s (%s) to %s", libname, libid, libdir
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
logging.info(
|
logging.info(
|
||||||
"Local mirror of library %s (%s) at %s is still recent enough. Skipping it.",
|
"Local mirror of library %s (%s) at %s is still recent enough. Skipping it.",
|
||||||
@@ -193,9 +189,7 @@ def main():
|
|||||||
# Get size of directory (libdir) in bytes
|
# Get size of directory (libdir) in bytes
|
||||||
# Note: this is not fully equivalent with what `du` would show. It's
|
# Note: this is not fully equivalent with what `du` would show. It's
|
||||||
# caused by the fact that `du` considers filesystem block sizes
|
# caused by the fact that `du` considers filesystem block sizes
|
||||||
libdirsize = sum(
|
libdirsize = sum(f.stat().st_size for f in libdir.glob("**/*") if f.is_file())
|
||||||
f.stat().st_size for f in libdir.glob("**/*") if f.is_file()
|
|
||||||
)
|
|
||||||
|
|
||||||
# Update libsdone and cache
|
# Update libsdone and cache
|
||||||
libsdone["libs"].append(libname)
|
libsdone["libs"].append(libname)
|
||||||
|
|||||||
Reference in New Issue
Block a user