diff --git a/files.py b/files.py index ff23461..544c941 100644 --- a/files.py +++ b/files.py @@ -189,6 +189,9 @@ def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ): # okay the root cwd is fake, so treat it specially - its Dir can be found by path with dir.rel_path='' if os.path.dirname(cwd) == 'static': dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path=='').filter(Path.path_prefix==prefix).order_by(Entry.name).first() + # this can occur if the path in settings does not exist as it wont be in # the DB + if not dir: + return entries # although this is 1 entry, needs to come back via all() to be iterable entries+= Entry.query.filter(Entry.id==dir.id).all() else: @@ -197,6 +200,9 @@ def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ): 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() + # this can occur if the path in settings does not exist as it wont be in # the DB + if not dir: + return entries if noo == "Z to A" or "Newest": entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name.desc()).all() # just do A to Z / Oldest by default or if no valid option