fixed up dup code to work with paths, added path_types throughout and updated TODO to be clear on what next
This commit is contained in:
12
files.py
12
files.py
@@ -21,6 +21,7 @@ import re
|
||||
# Local Class imports
|
||||
################################################################################
|
||||
from job import Job, JobExtra, Joblog, NewJob
|
||||
from path import PathType, Path
|
||||
from person import Person, PersonRefimgLink
|
||||
from refimg import Refimg
|
||||
from settings import Settings
|
||||
@@ -41,15 +42,6 @@ class PathDirLink(db.Model):
|
||||
def __repr__(self):
|
||||
return f"<path_id: {self.path_id}, dir_eid: {self.dir_eid}>"
|
||||
|
||||
class Path(db.Model):
|
||||
__tablename__ = "path"
|
||||
id = db.Column(db.Integer, db.Sequence('path_id_seq'), primary_key=True )
|
||||
path_prefix = db.Column(db.String, unique=True, nullable=False )
|
||||
num_files = db.Column(db.Integer)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<id: {self.id}, path_prefix: {self.path_prefix}, num_files={self.num_files}>"
|
||||
|
||||
class EntryDirLink(db.Model):
|
||||
__tablename__ = "entry_dir_link"
|
||||
entry_id = db.Column(db.Integer, db.ForeignKey("entry.id"), primary_key=True )
|
||||
@@ -277,7 +269,7 @@ def scan_sp():
|
||||
|
||||
@app.route("/fix_dups", methods=["POST"])
|
||||
def fix_dups():
|
||||
rows = db.engine.execute( "select e1.id as id1, f1.hash, d1.path_prefix as path1, d1.eid as did1, e1.name as fname1, e2.id as id2, d2.path_prefix as path2, d2.eid as did2, e2.name as fname2 from entry e1, file f1, dir d1, entry_dir_link edl1, entry e2, file f2, dir d2, entry_dir_link edl2 where e1.id = f1.eid and e2.id = f2.eid and d1.eid = edl1.dir_eid and edl1.entry_id = e1.id and edl2.dir_eid = d2.eid and edl2.entry_id = e2.id and f1.hash = f2.hash and e1.id != e2.id and f1.size_mb = f2.size_mb order by path1, fname1" )
|
||||
rows = db.engine.execute( "select e1.id as id1, f1.hash, d1.rel_path as rel_path1, d1.eid as did1, e1.name as fname1, p1.id as path1, p1.type_id as path_type1, e2.id as id2, d2.rel_path as rel_path2, d2.eid as did2, e2.name as fname2, p2.id as path2, p2.type_id as path_type2 from entry e1, file f1, dir d1, entry_dir_link edl1, path_dir_link pdl1, path p1, entry e2, file f2, dir d2, entry_dir_link edl2, path_dir_link pdl2, path p2 where e1.id = f1.eid and e2.id = f2.eid and d1.eid = edl1.dir_eid and edl1.entry_id = e1.id and edl2.dir_eid = d2.eid and edl2.entry_id = e2.id and p1.id = pdl1.path_id and pdl1.dir_eid = d1.eid and p2.id = pdl2.path_id and pdl2.dir_eid = d2.eid and f1.hash = f2.hash and e1.id != e2.id and f1.size_mb = f2.size_mb order by path1, fname1" )
|
||||
|
||||
if rows.returns_rows == False:
|
||||
st.SetAlert("success")
|
||||
|
||||
Reference in New Issue
Block a user