diff --git a/RefactorPlan b/RefactorPlan index dea7005f..ef776353 100644 --- a/RefactorPlan +++ b/RefactorPlan @@ -25,11 +25,8 @@ exception confusion. These two functions should be a lot simpler. * get_file_hashes is overly complex and contains strange code like: for r, d, f in os.walk(parent, topdown=False): pass -* dir_size tries to calculate symlink lengths, this is probably not very -helpful, since in most cases, they fit in the inode, and wont take any -extra space at all. We can keep the number of file in the index though. -That way we can calculate package size + (nr of files * inode size of fs) -to give a more correct required disk size. +* To estimate required disk size for the packages more accurately we can +calculate package size + (nr of files * inode size of fs). * Why in a world like this there exists *parse_package* util functions? These must be all methods of package class diff --git a/pisi/util.py b/pisi/util.py index b191aafa..69457798 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -296,13 +296,13 @@ def dir_size(dir): return getsize(dir) if islink(dir): - return long(len(os.readlink(dir))) + return 0 def sizes(): for root, dirs, files in os.walk(dir): - yield sum([getsize(join(root, name)) for name in files if not islink(join(root,name))]) - yield sum([long(len(os.readlink((join(root, name))))) for name in files if islink(join(root,name))]) - return sum( sizes() ) + yield sum([getsize(join(root, name)) for name in files if not islink(join(root, name))]) + yield sum([long(len(os.readlink((join(root, name))))) for name in files if islink(join(root, name))]) + return sum(sizes()) def copy_file(src,dest): """Copy source file to the destination file."""