修复快照被意外删除的问题
parent
0684e29098
commit
fc61cf16ed
|
@ -87,7 +87,7 @@ const initDeviceInfo = () => {
|
||||||
}
|
}
|
||||||
const devices = store.get('clients') as DevicesInfo['clients'] | undefined
|
const devices = store.get('clients') as DevicesInfo['clients'] | undefined
|
||||||
if (devices) devicesInfo.clients = devices
|
if (devices) devicesInfo.clients = devices
|
||||||
deviceKeys = Object.values(devicesInfo.clients).map(device => device.key).filter(k => k)
|
deviceKeys = Object.values(devicesInfo.clients).map(device => device.snapshotKey).filter(k => k)
|
||||||
const snapshotInfo = store.get('snapshotInfo') as DevicesInfo['snapshotInfo'] | undefined
|
const snapshotInfo = store.get('snapshotInfo') as DevicesInfo['snapshotInfo'] | undefined
|
||||||
if (snapshotInfo) devicesInfo.snapshotInfo = snapshotInfo
|
if (snapshotInfo) devicesInfo.snapshotInfo = snapshotInfo
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ export const saveClientKeyInfo = (keyInfo: LX.Sync.ServerKeyInfo) => {
|
||||||
}
|
}
|
||||||
export const getClientKeyInfo = (clientId?: string): LX.Sync.ServerKeyInfo | null => {
|
export const getClientKeyInfo = (clientId?: string): LX.Sync.ServerKeyInfo | null => {
|
||||||
if (!clientId) return null
|
if (!clientId) return null
|
||||||
|
if (!devicesInfo.serverId) initDeviceInfo()
|
||||||
return devicesInfo.clients[clientId] ?? null
|
return devicesInfo.clients[clientId] ?? null
|
||||||
}
|
}
|
||||||
export const getServerId = (): string => {
|
export const getServerId = (): string => {
|
||||||
|
|
|
@ -219,6 +219,10 @@ const overwriteList = (sourceListData: LX.Sync.ListData, targetListData: LX.Sync
|
||||||
const handleMergeListData = async(socket: LX.Sync.Server.Socket): Promise<[LX.Sync.ListData, boolean, boolean]> => {
|
const handleMergeListData = async(socket: LX.Sync.Server.Socket): Promise<[LX.Sync.ListData, boolean, boolean]> => {
|
||||||
const mode: LX.Sync.Mode = await getSyncMode(socket)
|
const mode: LX.Sync.Mode = await getSyncMode(socket)
|
||||||
|
|
||||||
|
if (mode == 'cancel') {
|
||||||
|
socket.close(SYNC_CLOSE_CODE.normal)
|
||||||
|
throw new Error('cancel')
|
||||||
|
}
|
||||||
const [remoteListData, localListData] = await Promise.all([getRemoteListData(socket), getLocalListData()])
|
const [remoteListData, localListData] = await Promise.all([getRemoteListData(socket), getLocalListData()])
|
||||||
console.log('handleMergeListData', 'remoteListData, localListData')
|
console.log('handleMergeListData', 'remoteListData, localListData')
|
||||||
let listData: LX.Sync.ListData
|
let listData: LX.Sync.ListData
|
||||||
|
@ -246,7 +250,7 @@ const handleMergeListData = async(socket: LX.Sync.Server.Socket): Promise<[LX.Sy
|
||||||
requiredUpdateRemoteListData = false
|
requiredUpdateRemoteListData = false
|
||||||
break
|
break
|
||||||
// case 'none': return null
|
// case 'none': return null
|
||||||
case 'cancel':
|
// case 'cancel':
|
||||||
default:
|
default:
|
||||||
socket.close(SYNC_CLOSE_CODE.normal)
|
socket.close(SYNC_CLOSE_CODE.normal)
|
||||||
throw new Error('cancel')
|
throw new Error('cancel')
|
||||||
|
|
Loading…
Reference in New Issue