diff --git a/agkyra/nwgui/notify.js b/agkyra/nwgui/notify.js index a3fde132ab7ea3b99b0c2328eb321664fdf40b58..2a54fd88b958f3cb7c41e26ca4b1837500f8bc09 100644 --- a/agkyra/nwgui/notify.js +++ b/agkyra/nwgui/notify.js @@ -17,7 +17,9 @@ var NOTIFICATION = { function is_up(code) { return (code / 100 >> 0) === 1; } function has_settings_error(code) { return (code / 200 >> 0) === 2; } -function remaining(status) { return status.unsynced - status.synced; } +function remaining(status) { + return status.unsynced - (status.synced + status.failed); +} var ntf_title = { 'info': 'Agkyra Notification', diff --git a/agkyra/nwgui/protocol.js b/agkyra/nwgui/protocol.js index e33110f9ff9fec58c20921abfe33fbba368703ef..2e8d4fcdccb7a6fc5a3dc120bf7dd710b560fd0e 100644 --- a/agkyra/nwgui/protocol.js +++ b/agkyra/nwgui/protocol.js @@ -39,7 +39,7 @@ var globals = { directory: null, exclude: null }, - status: {synced: 0, unsynced: 0, code: STATUS['UNINITIALIZED']}, + status: {synced: 0, unsynced: 0, failed: 0, code: STATUS['UNINITIALIZED']}, authenticated: false, open_settings: false, settings_are_open: false, @@ -82,7 +82,7 @@ function put_settings(socket, new_settings) { function get_status(socket) { send_json(socket, {'method': 'get', 'path': 'status'}); -} // expected response {"synced":.., "unsynced":.., "code":..} +} // expected response {"synced":.., "unsynced":.., "failed":..., code":..} // Connect to helper diff --git a/agkyra/protocol.py b/agkyra/protocol.py index 5dd0aa73bb23a1eecd82ebc8c129367eca02d747..66dae8a06a2e67856b9596340b39354d9f4e4dc0 100644 --- a/agkyra/protocol.py +++ b/agkyra/protocol.py @@ -252,14 +252,13 @@ class WebSocketProtocol(WebSocket): -- GET STATUS -- GUI: {"method": "get", "path": "status"} HELPER: {"code": <int>, - "synced": <int>, - "unsynced": <int>, + "synced": <int>, "unsynced": <int>, "failed": <int>, "action": "get status" } or {<ERROR>: <ERROR CODE>, "action": "get status"} """ status = utils.ThreadSafeDict() with status.lock() as d: - d.update(code=STATUS['UNINITIALIZED'], synced=0, unsynced=0) + d.update(code=STATUS['UNINITIALIZED'], synced=0, unsynced=0, failed=0) ui_id = None session_db, session_relation = None, None @@ -279,7 +278,7 @@ class WebSocketProtocol(WebSocket): if self.syncer.paused: d['code'] = STATUS['PAUSED'] elif d['code'] != STATUS['PAUSING'] or ( - d['unsynced'] == d['synced']): + d['unsynced'] == d['synced'] + d['failed']): d['code'] = STATUS['SYNCING'] with self.status.lock() as d: return d.get(key, None) if key else dict(d) @@ -441,10 +440,10 @@ class WebSocketProtocol(WebSocket): """Update status by consuming and understanding syncer messages""" if self.can_sync(): msg = self.syncer.get_next_message() - if not msg: - with self.status.lock() as d: - if d['unsynced'] == d['synced']: - d.update(unsynced=0, synced=0) + # if not msg: + # with self.status.lock() as d: + # if d['unsynced'] == d['synced'] + d['failed']: + # d.update(unsynced=0, synced=0, failed=0) while msg: if isinstance(msg, messaging.SyncMessage): LOG.error('UNSYNCED +1') @@ -452,6 +451,9 @@ class WebSocketProtocol(WebSocket): elif isinstance(msg, messaging.AckSyncMessage): LOG.error('SYNCED +1') self.set_status(synced=self.get_status('synced') + 1) + elif isinstance(msg, messaging.SyncErrorMessage): + LOG.error('FAILED +1') + self.set_status(failed=self.get_status('failed') + 1) elif isinstance(msg, messaging.LocalfsSyncDisabled): self.set_status(code=STATUS['DIRECTORY ERROR']) self.syncer.stop_all_daemons() @@ -461,10 +463,10 @@ class WebSocketProtocol(WebSocket): LOG.debug('Backend message: %s' % msg.name) # Limit the amount of messages consumed each time max_consumption -= 1 - if not max_consumption: - break - else: + if max_consumption: msg = self.syncer.get_next_message() + else: + break def can_sync(self): """Check if settings are enough to setup a syncing proccess"""