Commit 271b1a82 authored by inkhey's avatar inkhey
Browse files

correct dir size

parent fd740c26
......@@ -119,7 +119,15 @@ class sqlGit(object):
values (?,?,?,?);''', data)
def insert_file(self, depth):
def _get_size_dir(self,path):
total_size = 0
for dirpath, dirnames, filenames in os.walk(path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
def insert_file(self,depth):
''' insert file data into file table, depth define how precise
file data will be.'''
if depth > 0:
......@@ -131,7 +139,7 @@ class sqlGit(object):
for root, dirs, files in filtered_walk(".", depth=depth):
for fn in files:
path = os.path.join(root, fn)
size = os.stat(path).st_size
size = os.path.getsize(path)
data = (fn, size, root)
'''INSERT INTO file(name,size,dir)
......@@ -141,14 +149,14 @@ class sqlGit(object):
for d in dirs:
path = os.path.join(root, d)
size = os.stat(path).st_size
size = self._get_size_dir(path)
data = (d, size, root)
'''INSERT INTO file(name,size,dir)
values (?,?,?);''', data)
def insert_link_A_C(self):
''' insert link data between author and commit into
link_author_commits table'''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment