eslint
This commit is contained in:
@@ -146,7 +146,7 @@ const broadcast = async(action: listAction, data: any, excludeIds: string[] = []
|
||||
export const sendListAction = async(action: LX.Sync.ActionList) => {
|
||||
console.log('sendListAction', action.action)
|
||||
// io.sockets
|
||||
return await broadcast('list:action', JSON.stringify(action))
|
||||
await broadcast('list:action', JSON.stringify(action))
|
||||
}
|
||||
|
||||
export const registerListHandler = (_io: Server, socket: LX.Sync.Socket) => {
|
||||
|
||||
@@ -142,7 +142,10 @@ const handleStartServer = async(port = 9527) => await new Promise((resolve, reje
|
||||
|
||||
httpServer.on('listening', () => {
|
||||
const addr = httpServer.address()
|
||||
if (!addr) return reject(new Error('address is null'))
|
||||
if (!addr) {
|
||||
reject(new Error('address is null'))
|
||||
return
|
||||
}
|
||||
const bind = typeof addr == 'string' ? `pipe ${addr}` : `port ${addr.port}`
|
||||
console.info(`Listening on ${bind}`)
|
||||
resolve(null)
|
||||
@@ -171,7 +174,7 @@ export const stopServer = async() => {
|
||||
return
|
||||
}
|
||||
console.log('stoping sync server...')
|
||||
return await handleStopServer().then(() => {
|
||||
await handleStopServer().then(() => {
|
||||
console.log('sync server stoped')
|
||||
status.status = false
|
||||
status.message = ''
|
||||
@@ -189,7 +192,7 @@ export const startServer = async(port: number) => {
|
||||
if (status.status) await handleStopServer()
|
||||
|
||||
console.log('starting sync server...')
|
||||
return await handleStartServer(port).then(() => {
|
||||
await handleStartServer(port).then(() => {
|
||||
console.log('sync server started')
|
||||
status.status = true
|
||||
status.message = ''
|
||||
|
||||
@@ -31,7 +31,10 @@ const getRemoteListData = async(socket: LX.Sync.Socket): Promise<LX.Sync.ListDat
|
||||
socket.removeListener('list:sync', handleSuccess)
|
||||
console.log('getRemoteListData', 'handleSuccess')
|
||||
const data: LX.Sync.Data | null = JSON.parse(decryptMsg(socket.data.keyInfo, enData))
|
||||
if (!data) return reject(new Error('Get remote list data failed'))
|
||||
if (!data) {
|
||||
reject(new Error('Get remote list data failed'))
|
||||
return
|
||||
}
|
||||
if (data.action != 'getData') return
|
||||
resolve(patchListData(data.data))
|
||||
}
|
||||
@@ -101,10 +104,10 @@ const updateSnapshot = async(path: string, data: string) => {
|
||||
let writeFilePromise = writeFilePromises.get(path) ?? Promise.resolve()
|
||||
writeFilePromise = writeFilePromise.then(async() => {
|
||||
if (writeFilePromise !== writeFilePromises.get(path)) return
|
||||
return await fsPromises.writeFile(path, data)
|
||||
await fsPromises.writeFile(path, data)
|
||||
})
|
||||
writeFilePromises.set(path, writeFilePromise)
|
||||
return await writeFilePromise.finally(() => {
|
||||
await writeFilePromise.finally(() => {
|
||||
if (writeFilePromise !== writeFilePromises.get(path)) return
|
||||
writeFilePromises.delete(path)
|
||||
})
|
||||
@@ -453,7 +456,7 @@ const checkSyncQueue = async(): Promise<void> => {
|
||||
if (!syncingId) return
|
||||
console.log('sync queue...')
|
||||
await wait()
|
||||
return await checkSyncQueue()
|
||||
await checkSyncQueue()
|
||||
}
|
||||
|
||||
// export {
|
||||
@@ -484,7 +487,7 @@ const _syncList = async(_io: Server, socket: LX.Sync.Socket) => {
|
||||
|
||||
const removeSnapshot = async(keyInfo: LX.Sync.KeyInfo) => {
|
||||
const filePath = getSnapshotFilePath(keyInfo)
|
||||
return await fsPromises.unlink(filePath)
|
||||
await fsPromises.unlink(filePath)
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user