changed files table to file to be consistent with other tables in the db

This commit is contained in:
2021-01-14 21:58:20 +11:00
parent 348c9132f2
commit a93f9e1da8
3 changed files with 11 additions and 13 deletions

View File

@@ -26,10 +26,6 @@ class FileData():
def __init__(self):
self.view_list=[]
################################################################################
# Utility Functions for Files
################################################################################
def getExif(self, file):
f = open(file, 'rb')
try:
@@ -99,6 +95,8 @@ class FileData():
##############################################################################
def GenerateFileData(self):
settings = Settings.query.all()
if not settings:
return
last_import_date = settings[0].last_import_date
paths = settings[0].import_path.split("#")
@@ -140,21 +138,21 @@ class FileData():
fsize = round(os.stat(file).st_size/(1024*1024))
fname=file.replace(path, "")
path_prefix=symlink.replace(path,"")
file_obj = Files( name=fname, type=ftype, size_mb=fsize, hash=fhash, path_prefix=path_prefix, thumbnail=fthumbnail )
file_obj = File( name=fname, type=ftype, size_mb=fsize, hash=fhash, path_prefix=path_prefix, thumbnail=fthumbnail )
db.session.add(file_obj)
else:
print( "{} - {} is OLDER than {}".format( file, stat.st_ctime, last_import_date ) )
settings[0].last_import_date = time.time()
db.session.commit()
self.view_list = Files.query.all()
self.view_list = File.query.all()
return self
################################################################################
# Class describing Files in the database, and via sqlalchemy, connected to the DB as well
# Class describing File in the database, and via sqlalchemy, connected to the DB as well
# This has to match one-for-one the DB table
################################################################################
class Files(db.Model):
id = db.Column(db.Integer, db.Sequence('files_id_seq'), primary_key=True )
class File(db.Model):
id = db.Column(db.Integer, db.Sequence('file_id_seq'), primary_key=True )
name = db.Column(db.String, unique=True, nullable=False )
type = db.Column(db.String, unique=False, nullable=False)
path_prefix = db.Column(db.String, unique=False, nullable=False)
@@ -200,7 +198,7 @@ def scannow():
################################################################################
@app.route("/files/forcescan", methods=["GET"])
def forcescan():
Files.query.delete()
File.query.delete()
Settings.query.all()[0].last_import_date=0
db.session.commit()
filedata.GenerateFileData()