def GET(self): inputs = web.webapi.input(repo='') sync_status = {} repo = get_repo(inputs.repo) if not repo or not repo.props.worktree or not repo.props.head_branch: return json.dumps(sync_status) relay = get_relay_of_repo(repo) if relay: if relay.props.net_state != NET_STATE_CONNECTED: sync_status['state'] = 'relay not connected' return json.dumps(sync_status) t = seafile_rpc.get_repo_sync_task(inputs.repo) if t: if t.props.state == 'error' and t.props.error == 'relay not connected': # Hide the 'relay not connected' error from daemon when relay # is actually connected, but the check sync pulse has not come yet sync_status['state'] = 'waiting for sync' return json.dumps(sync_status) elif t.props.state == 'canceled' or t.props.state == 'cancel pending': sync_status['state'] = 'waiting for sync' else: sync_status['state'] = t.props.state sync_status['is_sync_lan'] = t.props.is_sync_lan sync_status['error'] = t.props.error else: # No sync task yet: seafile maybe have just been started sync_status['state'] = 'waiting for sync' if sync_status['state'] == 'waiting for sync' and not repo.props.auto_sync: sync_status['state'] = 'auto sync is turned off' return json.dumps(sync_status)
def GET(self): inputs = web.webapi.input(repo='') sync_status = {} repo = get_repo(inputs.repo) if not repo or not repo.props.worktree or not repo.props.head_branch: return json.dumps(sync_status) relay = get_relay_of_repo(repo) if relay: if not relay.props.is_ready: if relay.net_state != NET_STATE_CONNECTED: sync_status['state'] = 'relay not connected' else: sync_status['state'] = 'relay authenticating' return json.dumps(sync_status) t = seafile_rpc.get_repo_sync_task(inputs.repo) if t: if t.props.state == 'error' and t.props.error == 'relay not connected': # Hide the 'relay not connected' error from daemon when relay # is actually connected, but the check sync pulse has not come yet sync_status['state'] = 'waiting for sync' return json.dumps(sync_status) elif t.props.state == 'canceled' or t.props.state == 'cancel pending': sync_status['state'] = 'waiting for sync' else: sync_status['state'] = t.props.state sync_status['is_sync_lan'] = t.props.is_sync_lan sync_status['error'] = t.props.error else: # No sync task yet: seafile maybe have just been started sync_status['state'] = 'waiting for sync' auto_sync_enabled = seafile_rpc.is_auto_sync_enabled() if not auto_sync_enabled or not repo.props.auto_sync: sync_status['state'] = 'auto sync is turned off' return json.dumps(sync_status)
def GET(self): inputs = web.webapi.input(repo="") sync_status = {} repo = get_repo(inputs.repo) if not repo or not repo.props.worktree or not repo.props.head_branch: return json.dumps(sync_status) relay = get_relay_of_repo(repo) if relay: if not relay.props.is_ready: if relay.net_state != NET_STATE_CONNECTED: sync_status["state"] = "relay not connected" else: sync_status["state"] = "relay authenticating" return json.dumps(sync_status) t = seafile_rpc.get_repo_sync_task(inputs.repo) if t: if t.props.state == "error" and t.props.error == "relay not connected": # Hide the 'relay not connected' error from daemon when relay # is actually connected, but the check sync pulse has not come yet sync_status["state"] = "waiting for sync" return json.dumps(sync_status) elif t.props.state == "canceled" or t.props.state == "cancel pending": sync_status["state"] = "waiting for sync" else: sync_status["state"] = t.props.state sync_status["is_sync_lan"] = t.props.is_sync_lan sync_status["error"] = t.props.error else: # No sync task yet: seafile maybe have just been started sync_status["state"] = "waiting for sync" auto_sync_enabled = seafile_rpc.is_auto_sync_enabled() if not auto_sync_enabled or not repo.props.auto_sync: sync_status["state"] = "auto sync is turned off" return json.dumps(sync_status)