Skip to content
Snippets Groups Projects
Commit 6b9ad3b6 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Fix error where Stream.activate wouldn't return stream

parent 245880e9
No related branches found
No related tags found
No related merge requests found
...@@ -314,25 +314,29 @@ class StreamList(): ...@@ -314,25 +314,29 @@ class StreamList():
Replace the first matching stream if the password is valid or the Replace the first matching stream if the password is valid or the
password protection period has perished password protection period has perished
""" """
for existing_stream in self.streams: for i, existing_stream in enumerate(self.streams):
if existing_stream.key == stream.key: if existing_stream.key == stream.key:
if existing_stream.protected and existing_stream.password is None: if existing_stream.protected and existing_stream.password is None:
existing_stream = stream.set_protected(True).activate() existing_stream = stream.set_protected(True).activate()
self.logger.info("Replaced existing stream {}, because the protected stream has no password set".format(existing_stream)) self.streams[i] = existing_stream
self.logger.info("Replaced existing stream with {}, because the protected stream has no password set".format(existing_stream))
self.logger.debug("new stream was: {}".format(stream)) self.logger.debug("new stream was: {}".format(stream))
return True return True
elif existing_stream.protected and existing_stream.is_valid_password(stream.password): elif existing_stream.protected and existing_stream.is_valid_password(stream.password):
existing_stream = stream.set_protected(True).activate() existing_stream = stream.set_protected(True).activate()
self.logger.info("Replaced existing stream {}, because a valid password was supplied".format(existing_stream)) self.streams[i] = existing_stream
self.logger.info("Replaced existing stream with {}, because a valid password was supplied".format(existing_stream))
self.logger.debug("new stream was: {}".format(stream)) self.logger.debug("new stream was: {}".format(stream))
return True return True
elif existing_stream.is_valid_password(stream.password): elif existing_stream.is_valid_password(stream.password):
existing_stream = stream existing_stream = stream
self.logger.info("Replaced existing {}stream {} because a valid password was supplied".format(p, existing_stream)) self.streams[i] = existing_stream
self.logger.info("Replaced existing {}stream with {} because a valid password was supplied".format(p, existing_stream))
return True return True
elif not existing_stream.has_password_protection(self.password_protection_period): elif not existing_stream.has_password_protection(self.password_protection_period):
self.logger.info("Replaced existing stream {} because its password protection period is over ({}/{})".format(existing_stream, existing_stream.inactive_since(), self.password_protection_period)) self.logger.info("Replaced existing stream with {} because its password protection period is over ({}/{})".format(existing_stream, existing_stream.inactive_since(), self.password_protection_period))
existing_stream = stream existing_stream = stream
self.streams[i] = existing_stream
return True return True
self.logger.info("Didn't accept new stream {}, because a existing stream is protected".format(stream)) self.logger.info("Didn't accept new stream {}, because a existing stream is protected".format(stream))
return False return False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment