🐛
This commit is contained in:
@ -7,6 +7,10 @@ qbittorrentURL = "http://localhost:1340/api/v2/"
|
||||
moviePath = "/media/plex/Server/movies/"
|
||||
showPath = "/media/plex/Server/Shows/"
|
||||
|
||||
async def fileSize(fp):
|
||||
print(fp[:60],end="\r")
|
||||
return os.path.getsize(fp)
|
||||
|
||||
async def getSize(startPath,pathLength):
|
||||
logThis("Getting the size of "+startPath)
|
||||
totalSize = 0
|
||||
@ -15,7 +19,7 @@ async def getSize(startPath,pathLength):
|
||||
fp = os.path.join(dirpath, f)
|
||||
# skip if it is symbolic link
|
||||
if not os.path.islink(fp):
|
||||
totalSize += os.path.getsize(fp)
|
||||
totalSize += await fileSize(fp)
|
||||
|
||||
return totalSize
|
||||
|
||||
@ -276,7 +280,7 @@ class BedreNetflix():
|
||||
|
||||
async def directorySizes(self,ctx):
|
||||
logThis("Calculating directory size")
|
||||
message = await ctx.send("Calculating directory size. This might take a while.")
|
||||
message = await ctx.send("```Calculating directory size. This might take a while.```")
|
||||
startPath = ".."
|
||||
pathLength = len(startPath)
|
||||
directories = []
|
||||
@ -287,6 +291,17 @@ class BedreNetflix():
|
||||
else:
|
||||
size = await getSize(fp,pathLength)
|
||||
directories.append((str(f),size))
|
||||
directories.sort(key=lambda tup: tup[1])
|
||||
directories.reverse()
|
||||
returnText = "```Calculating directory size. This might take a while.\n"
|
||||
total = 0
|
||||
for directory, size in directories:
|
||||
total += size
|
||||
sizeText = await formatSize(size)
|
||||
returnText += "\n"+directory+": "+sizeText
|
||||
returnText += "\nTotal: "+await formatSize(total)+"```"
|
||||
await message.edit(content=returnText)
|
||||
|
||||
directories.sort(key=lambda tup: tup[1])
|
||||
directories.reverse()
|
||||
returnText = "```"
|
||||
@ -297,4 +312,5 @@ class BedreNetflix():
|
||||
returnText += "\n"+directory+": "+sizeText
|
||||
returnText += "\nTotal: "+await formatSize(total)+"```"
|
||||
|
||||
logThis("Returning final result of dirsize")
|
||||
await message.edit(content=returnText)
|
||||
|
Reference in New Issue
Block a user