1
0
mirror of https://github.com/ciromattia/kcc synced 2026-01-27 23:47:41 +00:00

Added volume auto-split

This commit is contained in:
Paweł Jastrzębski
2013-08-17 12:01:19 +02:00
parent 6eaf8cc374
commit f645b65a9e

View File

@@ -737,18 +737,35 @@ def splitDirectory(path, mode, parentPath):
if path != currentTarget:
move(os.path.join(root, name), os.path.join(currentTarget, name))
elif mode == 2:
for root, dirs, files in walkLevel(path, 1):
firstTome = True
for root, dirs, files in walkLevel(path, 0):
for name in dirs:
if root != path:
size = getDirectorySize(os.path.join(root, name))
if currentSize + size > 262144000:
size = getDirectorySize(os.path.join(root, name))
currentSize = 0
if size > 262144000:
if not firstTome:
currentTarget, pathRoot = createNewTome(parentPath)
output.append(pathRoot)
currentSize = size
else:
currentSize += size
if path != currentTarget:
firstTome = False
for rootInside, dirsInside, filesInside in walkLevel(os.path.join(root, name), 0):
for nameInside in dirsInside:
size = getDirectorySize(os.path.join(rootInside, nameInside))
if currentSize + size > 262144000:
currentTarget, pathRoot = createNewTome(parentPath)
output.append(pathRoot)
currentSize = size
else:
currentSize += size
if path != currentTarget:
move(os.path.join(rootInside, nameInside), os.path.join(currentTarget, nameInside))
else:
if not firstTome:
currentTarget, pathRoot = createNewTome(parentPath)
output.append(pathRoot)
move(os.path.join(root, name), os.path.join(currentTarget, name))
else:
firstTome = False
return output