browsing by folders should now only load contents of cwd from DB, faster, also removes bugs of that content not being in first 50 entries
This commit is contained in:
30
files.py
30
files.py
@@ -197,7 +197,9 @@ def files_ip():
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
|
||||
entries+=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
|
||||
|
||||
if folders:
|
||||
entries+=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).all()
|
||||
|
||||
return render_template("files.html", page_title='View Files (Import Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
|
||||
|
||||
@@ -215,12 +217,29 @@ def files_sp():
|
||||
for path in paths:
|
||||
prefix = SymlinkName("Storage",path,path+'/')
|
||||
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
if folders:
|
||||
# okay the root cwd is fake, so treat it specially - its Dir can be found by path with dir.rel_path=''
|
||||
if cwd == 'static/Storage':
|
||||
dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path=='').filter(Path.path_prefix==prefix).order_by(Entry.name).first()
|
||||
# although this is 1 entry, needs to come back via all() to be iterable
|
||||
entries+= Entry.query.filter(Entry.id==dir.id).all()
|
||||
else:
|
||||
rp = cwd.replace( prefix, '' )
|
||||
# when in subdirs, replacing prefix will leave the first char as /, get rid of it
|
||||
if len(rp) and rp[0] == '/':
|
||||
rp=rp[1:]
|
||||
dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path==rp).filter(Path.path_prefix==prefix).order_by(Entry.name).first()
|
||||
entries+= Entry.query.join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).all()
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
|
||||
entries+=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
|
||||
return render_template("files.html", page_title='View Files (Storage Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
|
||||
|
||||
|
||||
@@ -349,7 +368,6 @@ def rm_dups():
|
||||
def restore_files():
|
||||
jex=[]
|
||||
for el in request.form:
|
||||
print( f"{el}={request.form[el]}" )
|
||||
jex.append( JobExtra( name=f"{el}", value=request.form[el] ) )
|
||||
|
||||
job=NewJob( "restore_files", 0, None, jex )
|
||||
|
||||
Reference in New Issue
Block a user