removed debug print of video thumbnail, and made file importer look to see if file is newer than last import, if so, process it and store it in the database. If its older skip it. Then at the end of the function return the database as the list we process
This commit is contained in:
25
files.py
25
files.py
@@ -14,6 +14,7 @@ import exifread
|
|||||||
import base64
|
import base64
|
||||||
import numpy
|
import numpy
|
||||||
import cv2
|
import cv2
|
||||||
|
import time
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Local Class imports
|
# Local Class imports
|
||||||
@@ -91,7 +92,6 @@ class FileData():
|
|||||||
bt = thumb_buf.tostring()
|
bt = thumb_buf.tostring()
|
||||||
fthumbnail = base64.b64encode(bt)
|
fthumbnail = base64.b64encode(bt)
|
||||||
fthumbnail = str(fthumbnail)[2:-1]
|
fthumbnail = str(fthumbnail)[2:-1]
|
||||||
print(fthumbnail)
|
|
||||||
return fthumbnail
|
return fthumbnail
|
||||||
|
|
||||||
|
|
||||||
@@ -100,8 +100,10 @@ class FileData():
|
|||||||
# multiple valid paths in import_path) #
|
# multiple valid paths in import_path) #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
def GenerateFileData(self):
|
def GenerateFileData(self):
|
||||||
sets = Settings.query.filter(Settings.name=="import_path").all()
|
import_path = Settings.query.filter(Settings.name=="import_path").all()[0].value
|
||||||
paths= sets[0].value.split("#")
|
last_import_date_obj = Settings.query.filter(Settings.name=="last_import_date").all()
|
||||||
|
last_import_date = float(last_import_date_obj[0].value)
|
||||||
|
paths= import_path.split("#")
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
path = self.FixPath(path)
|
path = self.FixPath(path)
|
||||||
@@ -115,9 +117,12 @@ class FileData():
|
|||||||
|
|
||||||
self.file_list.append(glob.glob(self.view_path + '**', recursive=True))
|
self.file_list.append(glob.glob(self.view_path + '**', recursive=True))
|
||||||
for file in self.file_list[0]:
|
for file in self.file_list[0]:
|
||||||
fthumbnail = None
|
|
||||||
if file == path:
|
if file == path:
|
||||||
continue
|
continue
|
||||||
|
stat = os.stat(file)
|
||||||
|
if last_import_date == 0 or stat.st_ctime > last_import_date:
|
||||||
|
print( "{} - {} is newer than {}".format( file, stat.st_ctime, last_import_date ) )
|
||||||
|
fthumbnail = None
|
||||||
if os.path.isdir(file):
|
if os.path.isdir(file):
|
||||||
ftype = 'Directory'
|
ftype = 'Directory'
|
||||||
elif self.isImage(file):
|
elif self.isImage(file):
|
||||||
@@ -136,7 +141,15 @@ class FileData():
|
|||||||
|
|
||||||
fsize = round(os.stat(file).st_size/(1024*1024))
|
fsize = round(os.stat(file).st_size/(1024*1024))
|
||||||
fname=file.replace(path, "")
|
fname=file.replace(path, "")
|
||||||
self.view_list.append( Files( name=fname, type=ftype, size_mb=fsize, hash=fhash, thumbnail=fthumbnail ))
|
file_obj = Files( name=fname, type=ftype, size_mb=fsize, hash=fhash, thumbnail=fthumbnail )
|
||||||
|
print( file_obj )
|
||||||
|
db.session.add(file_obj)
|
||||||
|
else:
|
||||||
|
print( "{} - {} is OLDER than {}".format( file, stat.st_ctime, last_import_date ) )
|
||||||
|
last_import_date_obj[0].value = str(time.time())
|
||||||
|
db.session.commit()
|
||||||
|
file_obj = Files.query.filter().all()
|
||||||
|
self.view_list = file_obj
|
||||||
return self
|
return self
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -150,7 +163,7 @@ class Files(db.Model):
|
|||||||
size_mb = db.Column(db.Integer, unique=False, nullable=False)
|
size_mb = db.Column(db.Integer, unique=False, nullable=False)
|
||||||
# hash might not be unique, this could be the source of dupe problems
|
# hash might not be unique, this could be the source of dupe problems
|
||||||
hash = db.Column(db.Integer, unique=True, nullable=True)
|
hash = db.Column(db.Integer, unique=True, nullable=True)
|
||||||
thumbnail = db.Column(db.LargeBinary, unique=False, nullable=True)
|
thumbnail = db.Column(db.String, unique=False, nullable=True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<id: {}, name: {}>".format(self.id, self.name )
|
return "<id: {}, name: {}>".format(self.id, self.name )
|
||||||
|
|||||||
Reference in New Issue
Block a user