Skip to content

Commit cdf9e12

Browse files
committed
Remove previous button in case of single file directory
Make sure previous doesn't overlap with last item in directory
1 parent 9fe72b2 commit cdf9e12

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

pystream/models/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def parse_authorization(cls, value: Any) -> Dict[str, SecretStr]:
7171
raise ValueError("input should be a valid dictionary with username as key and password as value")
7272
r = {}
7373
for k, v in val.items():
74-
if len(k) < 3:
74+
if len(k) < 4:
7575
raise ValueError(f"[{k}: {v}] username should be at least 4 or more characters")
7676
if len(v) < 8:
7777
raise ValueError(f"[{k}: {v}] password should be at least 8 or more characters")

pystream/models/squire.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ def get_iter(filename: pathlib.PurePath) -> Union[Tuple[str, str], Tuple[None, N
103103
key=lambda x: natural_sort_key(x)
104104
)
105105
idx = dir_content.index(filename.name)
106-
try:
107-
previous_ = dir_content[idx - 1]
108-
except IndexError:
106+
if idx > 0: # 0-1 is -1, which will in turn fetch the last item from the list instead of leaving it blank
107+
try:
108+
previous_ = dir_content[idx - 1]
109+
if previous_ == filename.name: # This should be covered by > 0, but double check as a safety net
110+
previous_ = None
111+
except IndexError:
112+
previous_ = None
113+
else:
109114
previous_ = None
110115
try:
111116
next_ = dir_content[idx + 1]

0 commit comments

Comments
 (0)