diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-10-03 21:18:35 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-10-03 21:18:35 +0300 |
commit | c8163ab0cd08682eae783544b69f31755b85857f (patch) | |
tree | 2094289077966e2be28974e863bda803e965ffdb /core/models/survex.py | |
parent | 4495be2083e252802ce9c309b162bab27181ed0f (diff) | |
download | troggle-c8163ab0cd08682eae783544b69f31755b85857f.tar.gz troggle-c8163ab0cd08682eae783544b69f31755b85857f.tar.bz2 troggle-c8163ab0cd08682eae783544b69f31755b85857f.zip |
fix bug for wallet with empty fpath
Diffstat (limited to 'core/models/survex.py')
-rw-r--r-- | core/models/survex.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/models/survex.py b/core/models/survex.py index 1071537..b7c0b9b 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -277,15 +277,23 @@ class Wallet(models.Model): def get_fnames(self): '''Filenames without the suffix, i.e. without the ".jpg" ''' - dirpath = Path(settings.SCANS_ROOT, self.fpath) + dirpath = Path(settings.SCANS_ROOT, self.fpath) # does nowt as fpath is a rooted path already files = [] - if dirpath.is_dir(): + if not self.fpath: + files.append(f"Incorrect path to wallet contents: '{self.fpath}'") + return files + if not dirpath.is_dir(): + files.append(f"Incorrect path to wallet contents: '{self.fpath}'") + return files + else: try: for f in dirpath.iterdir(): if f.is_file(): - if f.name != 'contents.json' and f.name != 'walletindex.html': - files.append(Path(f.name).stem) + files.append(Path(f.name).stem) + else: + files.append(f"-{Path(f.name).stem}-") except FileNotFoundError: + files.append("FileNotFoundError") pass return files |