Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj committed Oct 19, 2023
1 parent f235dd8 commit 60c1040
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 399 deletions.
12 changes: 5 additions & 7 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ def do_scan(self, path, dictionary) :
try:
with scandir(path) as res:
folder_counter = 0
for entry in res:
#print(entry.name)

for entry in res:
try:
stat_res = stat(entry)
#print(type(stat_res))
except Exception as e:
print('stat error:%s', e )
else:
Expand All @@ -86,22 +84,21 @@ def do_scan(self, path, dictionary) :
is_symlink = entry.is_symlink()
size = stat_res.st_size

#dictionary[entry.name]=(is_dir,is_file,is_symlink,size,dict())

if is_dir:
if is_symlink :
new_level = (is_dir,is_file,is_symlink,size,stat_res.st_mtime_ns,None)
new_level = (is_dir,is_file,is_symlink,0,stat_res.st_mtime_ns,None)
print(f'skippping directory link: {path} / {entry.name}')
else:
new_dict=dict()
sub_level_size=self.do_scan(path_join(path,entry.name),new_dict)
new_level = (is_dir,is_file,is_symlink,sub_level_size,stat_res.st_mtime_ns,new_dict)
folder_size += sub_level_size
else:
new_level = (is_dir,is_file,is_symlink,size,stat_res.st_mtime_ns,None)
if is_symlink :
new_level = (is_dir,is_file,is_symlink,0,stat_res.st_mtime_ns,None)
print(f'skippping file link: {path} / {entry.name}')
else:
new_level = (is_dir,is_file,is_symlink,size,stat_res.st_mtime_ns,None)
folder_size += size

folder_counter += 1
Expand All @@ -110,6 +107,7 @@ def do_scan(self, path, dictionary) :

self.db.size += folder_size
self.db.files += folder_counter

except Exception as e:
print('scandir error:%s' % e )

Expand Down
Loading

0 comments on commit 60c1040

Please sign in to comment.