################################################################################
+def clean_empty_directories(session):
+ """
+ Removes empty directories from pool directories.
+ """
+
+ count = 0
+
+ cursor = session.execute(
+ "SELECT DISTINCT(path) FROM location WHERE type = :type",
+ {'type': 'pool'},
+ )
+ bases = [x[0] for x in cursor.fetchall()]
+
+ for base in bases:
+ for dirpath, dirnames, filenames in os.walk(base, topdown=False):
+ if not filenames and not dirnames:
+ if not Options["No-Action"]:
+ os.removedirs(os.path.join(base, dirpath))
+ count += 1
+
+ if count:
+ Logger.log(["total", count])
+ print "Cleaned %d empty directories from %d location(s)" % \
+ (count, len(bases))
+
+################################################################################
+
def main():
global Options, Logger
clean_maintainers(now_date, delete_date, max_delete, session)
clean_fingerprints(now_date, delete_date, max_delete, session)
clean_queue_build(now_date, delete_date, max_delete, session)
+ clean_empty_directories(session)
Logger.close()