From 5c720303734299317c9976b4b3c13d160af5e838 Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Sun, 13 Sep 2015 12:52:11 +0200 Subject: [PATCH] Rev396, Cleanup gevent event after connecting finished, Autofocus on notification input/button, Missing file size info error fix --- src/Config.py | 2 +- src/Connection/Connection.py | 8 ++++++-- src/Content/ContentManager.py | 4 ++-- src/Ui/media/Wrapper.coffee | 5 ++++- src/Ui/media/all.js | 10 ++++++++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Config.py b/src/Config.py index 5ef0fb5c..7c99c42e 100644 --- a/src/Config.py +++ b/src/Config.py @@ -8,7 +8,7 @@ class Config(object): def __init__(self, argv): self.version = "0.3.2" - self.rev = 395 + self.rev = 396 self.argv = argv self.action = None self.createParser() diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py index 5673252d..39e6a53d 100644 --- a/src/Connection/Connection.py +++ b/src/Connection/Connection.py @@ -85,8 +85,9 @@ class Connection(object): # Detect protocol self.send({"cmd": "handshake", "req_id": 0, "params": self.handshakeInfo()}) + event_connected = self.event_connected gevent.spawn(self.messageLoop) - return self.event_connected.get() # Wait for handshake + return event_connected.get() # Wait for handshake # Handle incoming connection def handleIncomingConnection(self, sock): @@ -170,6 +171,7 @@ class Connection(object): if crypt: self.crypt = crypt self.event_connected.set(True) # Mark handshake as done + self.event_connected = None # Handle incoming message def handleMessage(self, message): @@ -350,7 +352,8 @@ class Connection(object): return False # Already closed self.closed = True self.connected = False - self.event_connected.set(False) + if self.event_connected: + self.event_connected.set(False) if config.debug_socket: self.log( @@ -373,3 +376,4 @@ class Connection(object): # Little cleanup self.sock = None self.unpacker = None + self.event_connected = None diff --git a/src/Content/ContentManager.py b/src/Content/ContentManager.py index 13989900..9b4b0266 100644 --- a/src/Content/ContentManager.py +++ b/src/Content/ContentManager.py @@ -482,10 +482,10 @@ class ContentManager(object): hash_valid = CryptHash.sha1sum(file) == file_info["sha1"] else: hash_valid = False - if file_info["size"] != file.tell(): + if file_info.get("size", 0) != file.tell(): self.log.error( "%s file size does not match %s <> %s, Hash: %s" % - (inner_path, file.tell(), file_info["size"], hash_valid) + (inner_path, file.tell(), file_info.get("size", 0), hash_valid) ) return False return hash_valid diff --git a/src/Ui/media/Wrapper.coffee b/src/Ui/media/Wrapper.coffee index 9c30d592..6df4c371 100644 --- a/src/Ui/media/Wrapper.coffee +++ b/src/Ui/media/Wrapper.coffee @@ -117,6 +117,8 @@ class Wrapper body.append(button) @notifications.add("notification-#{caption}", "ask", body) + setTimeout (-> button.focus() ), 1500 + actionConfirm: (message, cb=false) -> message.params = @toHtmlSafe(message.params) # Escape html @@ -126,7 +128,6 @@ class Wrapper return false - displayPrompt: (message, type, caption, cb) -> body = $(""+message+"") @@ -144,6 +145,8 @@ class Wrapper @notifications.add("notification-#{message.id}", "ask", body) + setTimeout (-> input.focus() ), 1500 + actionPrompt: (message) -> message.params = @toHtmlSafe(message.params) # Escape html diff --git a/src/Ui/media/all.js b/src/Ui/media/all.js index eeef93ec..36ee7588 100644 --- a/src/Ui/media/all.js +++ b/src/Ui/media/all.js @@ -897,7 +897,10 @@ jQuery.extend( jQuery.easing, button = $("" + caption + ""); button.on("click", cb); body.append(button); - return this.notifications.add("notification-" + caption, "ask", body); + this.notifications.add("notification-" + caption, "ask", body); + return setTimeout((function() { + return button.focus(); + }), 1500); }; Wrapper.prototype.actionConfirm = function(message, cb) { @@ -943,7 +946,10 @@ jQuery.extend( jQuery.easing, }; })(this)); body.append(button); - return this.notifications.add("notification-" + message.id, "ask", body); + this.notifications.add("notification-" + message.id, "ask", body); + return setTimeout((function() { + return input.focus(); + }), 1500); }; Wrapper.prototype.actionPrompt = function(message) {