完善代码
This commit is contained in:
@@ -87,7 +87,7 @@ const defaultSetting = {
|
||||
},
|
||||
sync: {
|
||||
enable: false,
|
||||
port: 23332,
|
||||
port: '23332',
|
||||
},
|
||||
windowSizeId: 2,
|
||||
themeId: 0,
|
||||
|
||||
@@ -8,11 +8,8 @@ const { common: COMMON_EVENT_NAME } = require('@main/events/_name')
|
||||
const { throttle } = require('@common/utils')
|
||||
|
||||
let io
|
||||
// const checkFile = path => {
|
||||
// fsPromises.access(path, fs.constants.R_OK | fs.constants.W_OK)
|
||||
// .then(() => console.log('can access'))
|
||||
// .catch(() => console.error('cannot access'))
|
||||
// }
|
||||
let syncingId = null
|
||||
const wait = (time = 1000) => new Promise((resolve, reject) => setTimeout(resolve, time))
|
||||
|
||||
const getRemoteListData = socket => new Promise((resolve, reject) => {
|
||||
console.log('getRemoteListData')
|
||||
@@ -379,10 +376,19 @@ const syncList = async socket => {
|
||||
return handleMergeListDataFromSnapshot(socket, fileData)
|
||||
}
|
||||
|
||||
module.exports = (_io, socket) => {
|
||||
const checkSyncQueue = async() => {
|
||||
if (!syncingId) return
|
||||
await wait()
|
||||
return checkSyncQueue()
|
||||
}
|
||||
module.exports = async(_io, socket) => {
|
||||
io = _io
|
||||
await checkSyncQueue()
|
||||
syncingId = socket.data.keyInfo.clientId
|
||||
return syncList(socket).then(newListData => {
|
||||
registerUpdateSnapshotTask(socket, { ...newListData })
|
||||
return finishedSync(socket)
|
||||
}).finally(() => {
|
||||
syncingId = null
|
||||
})
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
"sync_address": "Synchronization service address: {address}",
|
||||
"sync_auth_code": "Connection code: {code}",
|
||||
"sync_device": "Connected devices: {devices}",
|
||||
"sync_enable": "Enable synchronization",
|
||||
"sync_enable": "Enable the synchronization function (please use it under a trusted network)",
|
||||
"sync_port": "Sync port settings",
|
||||
"sync_port_tip": "Please enter the synchronization service port number",
|
||||
"sync_refresh_code": "Refresh the connection code",
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
"sync_address": "同步服务地址:{address}",
|
||||
"sync_auth_code": "连接码:{code}",
|
||||
"sync_device": "已连接的设备:{devices}",
|
||||
"sync_enable": "启用同步功能",
|
||||
"sync_enable": "启用同步功能(请在受信任的网络下使用)",
|
||||
"sync_port": "同步端口设置",
|
||||
"sync_port_tip": "请输入同步服务端口号",
|
||||
"sync_refresh_code": "刷新连接码",
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
"sync_address": "同步服務地址:{address}",
|
||||
"sync_auth_code": "連接碼:{code}",
|
||||
"sync_device": "已連接的設備:{devices}",
|
||||
"sync_enable": "啟用同步功能",
|
||||
"sync_enable": "啟用同步功能(請在受信任的網絡下使用)",
|
||||
"sync_port": "同步端口設置",
|
||||
"sync_port_tip": "請輸入同步服務端口號",
|
||||
"sync_refresh_code": "刷新連接碼",
|
||||
|
||||
Reference in New Issue
Block a user