Resolve issues from DB lock collection migration
This commit is contained in:
1 parent
7a142a4c08
commit
d122b224b0
3 files changed
+10
-6
No files matched your search
@@ -39,6 +39,7 @@ import {
|
||||
} from "./ui/db";
|
||||
import * as common from "./util";
|
||||
import * as cache from "./cache";
|
||||
import { lockExists } from "./lock";
|
||||
import {
|
||||
getRevision,
|
||||
getConfig,
|
||||
@@ -211,8 +212,7 @@ export async function awaitSessionStart(
|
||||
);
|
||||
const li = (device["_lastInform"] as Date).getTime();
|
||||
if (li > lastInform) return true;
|
||||
const token = await cache.get(`cwmp_session_${deviceId}`);
|
||||
if (token) return true;
|
||||
if (await lockExists(`cwmp_session_${deviceId}`)) return true;
|
||||
if (timeout < 500) return false;
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
timeout -= Date.now() - now;
|
||||
@@ -224,8 +224,7 @@ export async function awaitSessionEnd(
|
||||
timeout: number
|
||||
): Promise<boolean> {
|
||||
const now = Date.now();
|
||||
const token = await cache.get(`cwmp_session_${deviceId}`);
|
||||
if (!token) return true;
|
||||
if (!(await lockExists(`cwmp_session_${deviceId}`))) return true;
|
||||
if (timeout < 500) return false;
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
timeout -= Date.now() - now;
|
||||
|
||||
Reference in new issue
Block a user