make sure force delete removes face links too. removed extra job debug logs. rewrite of ProcessRecycleBinDir to never import content, just call AddPath appropriately

This commit is contained in:
2021-07-03 12:01:51 +10:00
parent f66552bf81
commit 8818888596

View File

@@ -320,13 +320,23 @@ def MessageToFE( job_id, alert, message ):
session.commit()
return msg.id
def ProcessRecycleBinDir(parent_job):
def ProcessRecycleBinDir(job):
settings = session.query(Settings).first()
if settings == None:
raise Exception("Cannot create file data with no settings / recycle bin path is missing")
paths = settings.recycle_bin_path.split("#")
ptype = session.query(PathType).filter(PathType.name=='Bin').first()
JobsForPaths( parent_job, paths, ptype )
paths = settings.recycle_bin_path.split("#")
for path in paths:
if not os.path.exists( path ):
AddLogForJob( job, f"Not Importing {path} -- Path does not exist" )
continue
symlink=SymlinkName(ptype.name, path, path)
# create the Path (and Dir objects for the Bin)
AddPath( job, symlink, ptype.id )
session.commit()
return
def ProcessStorageDirs(parent_job):
@@ -520,6 +530,8 @@ def JobScanStorageDir(job):
def JobForceScan(job):
JobProgressState( job, "In Progress" )
session.query(FaceFileLink).delete()
session.query(FaceRefimgLink).delete()
session.query(DelFile).delete()
session.query(FileRefimgLink).delete()
session.query(EntryDirLink).delete()
@@ -954,6 +966,8 @@ def WrapperForScanFileForPerson(job, entry):
ppl=session.query(Person).filter(Person.tag==which_person).all()
if entry.type.name == 'Image':
if DEBUG:
AddLogForJob( job, f'INFO: processing File: {entry.name}' )
for person in ppl:
ScanFileForPerson( job, entry, person.id, force=False)
return
@@ -977,6 +991,8 @@ def JobRunAIOn(job):
ProcessFilesInDir( job, entry, WrapperForScanFileForPerson )
elif entry.type.name == 'Image':
which_file=session.query(Entry).join(File).filter(Entry.id==jex.value).first()
if DEBUG:
AddLogForJob( job, f'INFO: processing File: {entry.name}' )
for person in ppl:
ScanFileForPerson( job, which_file, person.id, force=False)
else:
@@ -1412,7 +1428,7 @@ def UnmatchedFacesForFile( eid ):
return rows
def ScanFileForPerson( job, e, person_id, force=False ):
AddLogForJob( job, f'INFO: Looking for person: {person_id} in file: {e.name}' )
# AddLogForJob( job, f'INFO: Looking for person: {person_id} in file: {e.name}' )
file_h = session.query(File).get( e.id )
# if we are forcing this, delete any old faces (this will also delete linked tables), and reset faces_created_on to None
if force: