diff --git a/pa_job_manager.py b/pa_job_manager.py index 3123a87..1af490e 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -313,7 +313,7 @@ def SymlinkName(path, file): # to serve static content of the images, we create a symlink from inside the static subdir of each import_path that exists def CreateSymlink(job,path): - symlink = FixPath('static/{}'.format( os.path.basename(path[0:-1]))) + symlink=os.path.join('static', os.path.basename(path[0:-1])) if not os.path.exists(symlink): os.symlink(path, symlink) return symlink @@ -371,7 +371,8 @@ def JobImportDir(job): return else: dir=AddDir(job, os.path.basename(path[0:-1]), symlink, None ) - keep_dirs[FixPath(dir.path_prefix)]=dir + session.commit() + keep_dirs[dir.path_prefix]=dir import_dir=dir fcnt[symlink]=0 files = sorted(glob.glob(path + '**', recursive=True)) @@ -386,15 +387,15 @@ def JobImportDir(job): fname=file.replace(path, "") stat = os.stat(file) dirname=SymlinkName(path, file) - if stat.st_ctime > keep_dirs[FixPath(dirname)].last_import_date: + if stat.st_ctime > keep_dirs[dirname].last_import_date: if DEBUG==1: - AddLogForJob(job, "DEBUG: {} - {} is newer than {}".format( file, stat.st_ctime, keep_dirs[FixPath(dirname)].last_import_date ), file ) - print("DEBUG: {} - {} is newer than {}".format( file, stat.st_ctime, keep_dirs[FixPath(dirname)].last_import_date ) ) + AddLogForJob(job, "DEBUG: {} - {} is newer than {}".format( file, stat.st_ctime, keep_dirs[dirname].last_import_date ), file ) + print("DEBUG: {} - {} is newer than {}".format( file, stat.st_ctime, keep_dirs[dirname].last_import_date ) ) if os.path.isdir(file): path_prefix=os.path.join(symlink,fname) dir=AddDir( job, fname, path_prefix, dir ) fcnt[path_prefix]=0 - keep_dirs[FixPath(dir.path_prefix)]=dir + keep_dirs[dir.path_prefix]=dir else: overall_file_cnt=overall_file_cnt+1 dirname=SymlinkName(path, file) @@ -409,8 +410,8 @@ def JobImportDir(job): e=AddFile( job, os.path.basename(fname), type_str, fsize, dir ) else: if DEBUG==1: - AddLogForJob(job, "DEBUG: {} - {} is OLDER than {}".format( file, stat.st_ctime, keep_dirs[FixPath(dirname)].last_import_date ), file ) - print("DEBUG: {} - {} is OLDER than {}".format( file, stat.st_ctime, keep_dirs[FixPath(dirname)].last_import_date ), file ) + AddLogForJob(job, "DEBUG: {} - {} is OLDER than {}".format( file, stat.st_ctime, keep_dirs[dirname].last_import_date ), file ) + print("DEBUG: {} - {} is OLDER than {}".format( file, stat.st_ctime, keep_dirs[dirname].last_import_date ), file ) FinishJob(job, "Finished Importing: {} - Found {} new files".format( path, overall_file_cnt ) ) for d in keep_dirs: keep_dirs[d].num_files = fcnt[d] @@ -460,7 +461,7 @@ def JobGetFileDetails(job): for jex in job.extra: if jex.name =="path": path=jex.value - path=FixPath('static/{}'.format( os.path.basename(path[0:-1]))) + path=os.path.join('static', os.path.basename(path[0:-1])) if DEBUG==1: print("DEBUG: JobGetFileDetails for path={}".format( path ) ) dir=session.query(Dir).filter(Dir.path_prefix==path).first()