changed files table to file to be consistent with other tables in the db
This commit is contained in:
18
files.py
18
files.py
@@ -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()
|
||||
|
||||
2
main.py
2
main.py
@@ -28,7 +28,7 @@ Bootstrap(app)
|
||||
|
||||
################################# Now, import non-book classes ###################################
|
||||
from settings import Settings
|
||||
from files import Files
|
||||
from files import File
|
||||
from person import Person
|
||||
from refimg import Refimg
|
||||
from job import Job
|
||||
|
||||
@@ -6,7 +6,7 @@ from sqlalchemy import Sequence
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from status import st, Status
|
||||
|
||||
from files import Files
|
||||
from files import File
|
||||
|
||||
################################################################################
|
||||
# Class describing Person in the database, and via sqlalchemy, connected to the DB as well
|
||||
@@ -22,7 +22,7 @@ class Person(db.Model):
|
||||
|
||||
class File_Person_Link(db.Model):
|
||||
__tablename__ = "file_person_link"
|
||||
file_id = db.Column(db.Integer, db.ForeignKey('files.id'), unique=True, nullable=False, primary_key=True)
|
||||
file_id = db.Column(db.Integer, db.ForeignKey('file.id'), unique=True, nullable=False, primary_key=True)
|
||||
person_id = db.Column(db.Integer, db.ForeignKey('person.id'), unique=True, nullable=False, primary_key=True)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user