From f4e8d5f9dae1ce3346221a382a4cac89f746ef15 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 22 Jun 2021 20:56:01 +1000 Subject: [PATCH] fix BUG, that occurred when I switch to folder view with a broken path in the settings -- the init validation only kicks up a fuss if there are no valid import paths, but if one is broken - as in DEV, when I reference Cams dev area, it was causing a dir match for that path to be None - simple if to fix --- files.py | 6 ++++++ 1 file changed, 6 insertions(+) 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