Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 39dbe9ff authored by ANDRADE-BARROSO Guillermo's avatar ANDRADE-BARROSO Guillermo
Browse files

fix get_doc

fix process update_data
parent aa3310e7
No related branches found
No related tags found
1 merge request!49update implementation to be compatible with overleaf version 5.2.1
Pipeline #1225832 failed
......@@ -905,50 +905,21 @@ class SyncClient:
# use thread local storage to pass the project data
storage = threading.local()
storage.is_data = False
class Namespace(BaseNamespace):
"""
Namespace.
"""
def on_connect(self) -> None:
"""
on_connect.
"""
logger.debug("[Connected] Yeah !!")
def on_reconnect(self) -> None:
"""
on_reconnect.
"""
logger.debug("[Reconnected] re-Yeah !!")
def on_disconnect(self) -> None:
"""
on_disconnect.
"""
logger.debug("[Disconnected] snif! ")
def on_connection_rejected(*args: Any) -> None:
"""
on_connection_rejected.
"""
logger.debug("[connectionRejected] oh !!!")
headers = {"Referer": url}
headers.update(self.headers)
with SocketIO(
self.base_url,
params={"projectId": project_id},
verify=self.verify,
Namespace=Namespace,
Namespace=LoggingNamespace,
cookies=self.cookie,
headers=headers,
) as socketIO:
def on_joint_doc(*args: Any) -> None:
"""
on_joint_doc.
"""
logger.debug("[socketIO] join doc ok")
# transform list of str (lines) as bytes for finally decode as
# utf-8 list of str
storage.doc_data = [
......@@ -960,24 +931,15 @@ class SyncClient:
"""
on_joint_project.
"""
storage.project_data = args[1]
storage.project_data = args[0]
socketIO.emit("joinDoc", doc_id, {"encodeRanges": True}, on_joint_doc)
def on_connection_accepted(*args: Any) -> None:
"""
on_connection_accepted.
"""
logger.debug("[connectionAccepted] Waoh !!!")
socketIO.emit(
"joinProject", {"project_id": project_id}, on_joint_project
)
socketIO.on("connectionAccepted", on_connection_accepted)
socketIO.on("connectionRejected", on_connection_rejected)
socketIO.on("joinProjectResponse", on_joint_project)
while not storage.is_data:
logger.debug("[socketIO] wait for doc data")
logger.debug("[socketIO] wait for project data")
socketIO.wait(0.1)
logger.debug("[socketIO] wait for doc data finish !")
logger.debug("[socketIO] wait for project data finish !")
# NOTE(msimonin): Check return type
if dest_path is None:
return "\n".join(storage.doc_data)
......@@ -1106,6 +1068,7 @@ class SyncClient:
"qqfilename": path_as_path.name,
"qqtotalfilesize": os.path.getsize(path_as_path),
}
breakpoint()
r = self._post(url, params=params, files=files, verify=self.verify)
r.raise_for_status()
response = r.json()
......
......@@ -666,7 +666,6 @@ def _sync_remote_docs(
update_data: UpdateDatum,
datetimes_dict: Mapping[str, datetime.datetime],
) -> None:
breakpoint()
remote_docs = (item for item in remote_items if item["type"] == "doc")
logger.debug("check if remote documents are newer that locals")
remote_time = datetime.datetime.now(datetime.timezone.utc)
......@@ -687,11 +686,26 @@ def _sync_remote_docs(
local_time = datetime.datetime.fromtimestamp(
local_path.stat().st_mtime, datetime.timezone.utc
)
updates = [
update["meta"]["end_ts"]
for update in update_data["updates"]
if doc_id in update["docs"]
]
if update_data["updates"]:
# check if have a new updates data structure
if "pathnames" in update_data["updates"][0]:
updates = []
for update in update_data["updates"]:
if relative_path in update["pathnames"]:
updates.append(update["meta"]["end_ts"])
else:
for op in update["project_ops"]:
for v in op.values():
if type(v) is dict:
if "pathname" in v:
if relative_path == v["pathname"]:
updates.append(update["meta"]["end_ts"])
else:
updates = [
update["meta"]["end_ts"]
for update in update_data["updates"]
if doc_id in update["docs"]
]
if len(updates) > 0:
remote_time = datetime.datetime.fromtimestamp(
updates[0] / 1000, datetime.timezone.utc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment