first pass of new viewing files "button bar"
This commit is contained in:
@@ -26,7 +26,7 @@ from sqlalchemy.orm import scoped_session
|
||||
### LOCAL FILE IMPORTS ###
|
||||
|
||||
from shared import DB_URL, PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, date
|
||||
import pytz
|
||||
import time
|
||||
import os
|
||||
@@ -42,8 +42,9 @@ import socket
|
||||
import threading
|
||||
import io
|
||||
import face_recognition
|
||||
import re
|
||||
|
||||
DEBUG=0
|
||||
DEBUG=1
|
||||
|
||||
# an Manager, which the Session will use for connection resources
|
||||
some_engine = create_engine(DB_URL)
|
||||
@@ -113,6 +114,10 @@ class File(Base):
|
||||
size_mb = Column(Integer, unique=False, nullable=False)
|
||||
hash = Column(Integer, unique=True, nullable=True)
|
||||
thumbnail = Column(String, unique=False, nullable=True)
|
||||
year = Column(Integer)
|
||||
month = Column(Integer)
|
||||
day = Column(Integer)
|
||||
woy = Column(Integer)
|
||||
last_hash_date = Column(Float)
|
||||
faces = Column( LargeBinary )
|
||||
faces_created_on = Column(Float)
|
||||
@@ -420,14 +425,14 @@ def AddDir(job, dirname, path_prefix, in_dir):
|
||||
session.add(e)
|
||||
return dir
|
||||
|
||||
def AddFile(job, fname, type_str, fsize, in_dir ):
|
||||
def AddFile(job, fname, type_str, fsize, in_dir, year, month, day, woy ):
|
||||
e=session.query(Entry).join(EntryDirLink).join(Dir).filter(Entry.name==fname,Dir.eid==in_dir.eid).first()
|
||||
if e:
|
||||
e.exists_on_fs=True
|
||||
return e
|
||||
ftype = session.query(FileType).filter(FileType.name==type_str).first()
|
||||
e=Entry( name=fname, type=ftype, exists_on_fs=True )
|
||||
f=File( size_mb=fsize, last_hash_date=0, faces_created_on=0 )
|
||||
f=File( size_mb=fsize, last_hash_date=0, faces_created_on=0, year=year, month=month, day=day, woy=woy )
|
||||
e.file_details.append(f)
|
||||
e.in_dir.append(in_dir)
|
||||
AddLogForJob(job, "Found new file: {}".format(fname) )
|
||||
@@ -503,6 +508,7 @@ def JobImportDir(job):
|
||||
if job.current_file_num % 100 == 0:
|
||||
session.commit()
|
||||
fname=dir.path_prefix+'/'+basename
|
||||
|
||||
stat = os.stat(fname)
|
||||
if stat.st_ctime > dir.last_import_date:
|
||||
AddLogForJob(job, f"Processing new/update file: {basename}", basename )
|
||||
@@ -515,7 +521,18 @@ def JobImportDir(job):
|
||||
else:
|
||||
type_str = 'Unknown'
|
||||
fsize = round(stat.st_size/(1024*1024))
|
||||
e=AddFile( job, basename, type_str, fsize, dir )
|
||||
m=re.search( '(\d{4})(\d{2})(\d{2})', fname)
|
||||
if m:
|
||||
year=int(m[1])
|
||||
month=int(m[2])
|
||||
day=int(m[3])
|
||||
else:
|
||||
year, month, day, _, _, _, _, _, _ = datetime.fromtimestamp(stat.st_ctime).timetuple()
|
||||
print(f"year={year}, month={month}, day={day}")
|
||||
c=date(year, month, day).isocalendar()
|
||||
woy=c[1]
|
||||
|
||||
e=AddFile( job, basename, type_str, fsize, dir, year, month, day, woy )
|
||||
else:
|
||||
e=session.query(Entry).filter(Entry.name==basename).first()
|
||||
e.exists_on_fs=True
|
||||
|
||||
Reference in New Issue
Block a user