-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.py
More file actions
22 lines (17 loc) · 716 Bytes
/
sync.py
File metadata and controls
22 lines (17 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import datetime
from enum import Enum
from data import *
class SYNC_RESULT(int, Enum):
FAIL = -1
SUCCESS = 0
SYNC = 1
def pack_result(result: SYNC_RESULT, sync_time:str, tab_list:list) -> dict:
return {"result":result,"sync_time":sync_time,"tab_list":tab_list}
def get_data() -> dict:
server_data = get_todo_data()
return pack_result(SYNC_RESULT.SUCCESS, server_data.get_sync_time(), server_data.get_tab_list())
def put_data(client_data) -> dict:
server_data = get_todo_data()
# 更新到客户端的数据, 同时更新时间点
new_sync_time = server_data.update_tab_list(client_data["tab_list"])
return pack_result(SYNC_RESULT.SUCCESS, server_data.get_sync_time(), [])