set parent_dir each time, not remember last dir as parent... that was simply dumb
This commit is contained in:
@@ -358,6 +358,7 @@ def JobsForPaths( parent_job, paths, ptype ):
|
|||||||
if parent_job:
|
if parent_job:
|
||||||
AddLogForJob(parent_job, "adding <a href='/job/{}'>job id={} {}</a> (wait for: {})".format( job3.id, job3.id, job3.name, job3.wait_for ) )
|
AddLogForJob(parent_job, "adding <a href='/job/{}'>job id={} {}</a> (wait for: {})".format( job3.id, job3.id, job3.name, job3.wait_for ) )
|
||||||
"""
|
"""
|
||||||
|
### FIXME: wait for job3 not job2!
|
||||||
job4=Job(start_time=now, last_update=now, name="checkdups", state="New", wait_for=job2.id, pa_job_state="New", current_file_num=0 )
|
job4=Job(start_time=now, last_update=now, name="checkdups", state="New", wait_for=job2.id, pa_job_state="New", current_file_num=0 )
|
||||||
session.add(job4)
|
session.add(job4)
|
||||||
session.commit()
|
session.commit()
|
||||||
@@ -797,13 +798,10 @@ def JobImportDir(job):
|
|||||||
overall_file_cnt+= len(subdirs) + len(files)
|
overall_file_cnt+= len(subdirs) + len(files)
|
||||||
path_obj.num_files=overall_file_cnt
|
path_obj.num_files=overall_file_cnt
|
||||||
|
|
||||||
# this is needed so that later on, when we AddDir for any dirs we find via os.walk, they have a parent dir object that is the dir for the path we are in
|
# find the dir we created with AddPath to use for entries at top-level of path
|
||||||
parent_dir=session.query(Dir).join(PathDirLink).join(Path).filter(Path.id==path_obj.id,Dir.rel_path=='').first()
|
dir=session.query(Dir).join(PathDirLink).join(Path).filter(Path.id==path_obj.id,Dir.rel_path=='').first()
|
||||||
|
|
||||||
# first time through we need dir to be the top level, we have a special if below to no recreate the top dir that AddPath created already
|
|
||||||
dir=parent_dir
|
|
||||||
# session.add in case we already have imported this dir (as AddDir wont) & now we might have diff num of files to last time,
|
# session.add in case we already have imported this dir (as AddDir wont) & now we might have diff num of files to last time,
|
||||||
session.add(parent_dir)
|
session.add(dir)
|
||||||
|
|
||||||
# if we set / then commit this now, the web page will know how many files
|
# if we set / then commit this now, the web page will know how many files
|
||||||
# to process as we then do the slow job of processing them
|
# to process as we then do the slow job of processing them
|
||||||
@@ -817,6 +815,7 @@ def JobImportDir(job):
|
|||||||
if root != path:
|
if root != path:
|
||||||
pp=SymlinkName( path_obj.type.name, path, root )+'/'+os.path.basename(root)
|
pp=SymlinkName( path_obj.type.name, path, root )+'/'+os.path.basename(root)
|
||||||
rel_path=pp.replace(symlink+'/','')
|
rel_path=pp.replace(symlink+'/','')
|
||||||
|
parent_dir=session.query(Dir).join(PathDirLink).join(Path).filter(Path.id==path_obj.id,Dir.rel_path==os.path.dirname(rel_path)).first()
|
||||||
dir=AddDir(job, os.path.basename(root), parent_dir, rel_path, path_obj)
|
dir=AddDir(job, os.path.basename(root), parent_dir, rel_path, path_obj)
|
||||||
for basename in files:
|
for basename in files:
|
||||||
# commit every 100 files to see progress being made but not hammer the database
|
# commit every 100 files to see progress being made but not hammer the database
|
||||||
@@ -847,7 +846,6 @@ def JobImportDir(job):
|
|||||||
job.current_file_num+=1
|
job.current_file_num+=1
|
||||||
job.current_file_num += len(subdirs)
|
job.current_file_num += len(subdirs)
|
||||||
dir.last_import_date = time.time()
|
dir.last_import_date = time.time()
|
||||||
parent_dir=dir
|
|
||||||
job.num_files=overall_file_cnt
|
job.num_files=overall_file_cnt
|
||||||
|
|
||||||
rm_cnt=HandleAnyFSDeletions(job)
|
rm_cnt=HandleAnyFSDeletions(job)
|
||||||
|
|||||||
Reference in New Issue
Block a user