fix BUG-64: can now move files into import or storage path

This commit is contained in:
2021-09-26 21:14:08 +10:00
parent 25a50d029f
commit 23c8d16a5b
7 changed files with 119 additions and 41 deletions

View File

@@ -1014,12 +1014,14 @@ def MoveFileToNewFolderInStorage(job,move_me, dst_storage_path, dst_rel_path):
print( f"MoveFileToNewFolderInStorage: {move_me} to {dst_storage_path} in new? folder: {dst_storage_path}")
try:
dst_dir=dst_storage_path.path_prefix + '/' + dst_rel_path
print( f"would make dir: {dst_dir}" )
if DEBUG:
print( f"would make dir: {dst_dir}" )
os.makedirs( dst_dir,mode=0o777, exist_ok=True )
src=move_me.FullPathOnFS()
dst=dst_dir + '/' + move_me.name
os.replace( src, dst )
print( f"would mv {src} {dst}" )
if DEBUG:
print( f"would mv {src} {dst}" )
except Exception as e:
print( f"ERROR: Failed to move file to new location on filesystem, err: {e}")
@@ -1032,14 +1034,17 @@ def MoveFileToNewFolderInStorage(job,move_me, dst_storage_path, dst_rel_path):
part_rel_path=""
for dirname in dst_rel_path.split("/"):
part_rel_path += f"{dirname}"
print( f"Should make a Dir in the DB for {dirname} with parent: {parent_dir}, prp={part_rel_path} in storage path" )
if DEBUG:
print( f"Should make a Dir in the DB for {dirname} with parent: {parent_dir}, prp={part_rel_path} in storage path" )
new_dir=AddDir( job, dirname, parent_dir, part_rel_path, dst_storage_path )
parent_dir=new_dir
part_rel_path += "/"
print( f"now should change {move_me} in_dir to {new_dir} created above in {dst_storage_path}" )
if DEBUG:
print( f"now should change {move_me} in_dir to {new_dir} created above in {dst_storage_path}" )
move_me.in_dir = new_dir
move_me.in_path = dst_storage_path
print( f"DONE change of {move_me} in_dir to {new_dir} created above" )
if DEBUG:
print( f"DONE change of {move_me} in_dir to {new_dir} created above" )
AddLogForJob(job, f"{move_me.name} - (moved to {os.path.dirname(move_me.FullPathOnFS())})" )
return
@@ -1263,7 +1268,6 @@ def JobRunAIOn(job):
session.commit()
for jex in job.extra:
print( jex )
if 'eid-' in jex.name:
entry=session.query(Entry).get(jex.value)
if entry.type.name == 'Directory':
@@ -1570,8 +1574,10 @@ def JobMoveFiles(job):
JobProgressState( job, "In Progress" )
prefix=[jex.value for jex in job.extra if jex.name == "prefix"][0]
suffix=[jex.value for jex in job.extra if jex.name == "suffix"][0]
storage_rp=[jex.value for jex in job.extra if jex.name == "storage_rp"][0]
dst_storage_path = session.query(Path).filter(Path.path_prefix=='static/Storage/'+ storage_rp).first()
path_type=[jex.value for jex in job.extra if jex.name == "move_path_type"][0]
rel_path=[jex.value for jex in job.extra if jex.name == "rel_path"][0]
dst_storage_path = session.query(Path).filter(Path.path_prefix=='static/' + path_type + '/'+ rel_path).first()
for jex in job.extra:
if 'eid-' in jex.name:
move_me=session.query(Entry).join(File).filter(Entry.id==jex.value).first()
@@ -1736,19 +1742,13 @@ def FindBestFaceMatch( dist, threshold ):
####################################################################################################################################
def ProcessFaceMatches( job, dist, threshold, e, name ):
while True:
print( f"ProcessFaceMatches() - finding best match left with dist={dist}" )
which_r, which_f, which_fd = FindBestFaceMatch( dist, threshold )
print( f"seems that best match is r={which_r}, f={which_f}, with fd={which_fd}" )
if which_r != None:
print( f"okay, which_r is real, so we have a match" )
MatchRefimgToFace( which_r, which_f, which_fd )
AddLogForJob(job, f'WE MATCHED: {name[which_r]} with file: {e.name} - face distance of {which_fd}')
# remove this refimg completely, cant be 2 of this person matched
print( f"now remove this refimg from dist" )
del( dist[which_r] )
# remove this face id completely, this face cant be matched by someone else
print( f"now remove this face from dist (if it is connected with anyone else)" )
print( f"dist now = {dist}" )
RemoveFaceNumFromDist( dist, which_f )
else:
return