fix: 🐛 more strange unlock calls

This commit is contained in:
ThatOneCalculator 2023-09-01 19:26:53 -07:00
parent 805230341e
commit 68dea6f0c3
No known key found for this signature in database
GPG key ID: 8703CACD01000000
5 changed files with 9 additions and 17 deletions

View file

@ -32,8 +32,6 @@ export default async function (
// Interrupt if you block the announcement destination // Interrupt if you block the announcement destination
if (await shouldBlockInstance(extractDbHost(uri))) return; if (await shouldBlockInstance(extractDbHost(uri))) return;
const unlock = await getApLock(uri);
try { try {
// Check if something with the same URI is already registered // Check if something with the same URI is already registered
const exist = await fetchNote(uri); const exist = await fetchNote(uri);
@ -60,9 +58,10 @@ export default async function (
throw e; throw e;
} }
if (!(await Notes.isVisibleForMe(renote, actor.id))) if (renote != null && !(await Notes.isVisibleForMe(renote, actor.id))) {
return "skip: invalid actor for this activity"; console.log("skip: invalid actor for this activity");
return;
}
logger.info(`Creating the (Re)Note: ${uri}`); logger.info(`Creating the (Re)Note: ${uri}`);
const activityAudience = await parseAudience( const activityAudience = await parseAudience(
@ -79,6 +78,6 @@ export default async function (
uri, uri,
}); });
} finally { } finally {
unlock(); await getApLock(uri);
} }
} }

View file

@ -31,8 +31,6 @@ export default async function (
} }
} }
const unlock = await getApLock(uri);
try { try {
const exist = await fetchNote(note); const exist = await fetchNote(note);
if (exist) return "skip: note exists"; if (exist) return "skip: note exists";
@ -46,6 +44,6 @@ export default async function (
throw e; throw e;
} }
} finally { } finally {
unlock(); await getApLock(uri);
} }
} }

View file

@ -13,8 +13,6 @@ export default async function (
): Promise<string> { ): Promise<string> {
logger.info(`Deleting the Note: ${uri}`); logger.info(`Deleting the Note: ${uri}`);
const unlock = await getApLock(uri);
try { try {
const dbResolver = new DbResolver(); const dbResolver = new DbResolver();
const note = await dbResolver.getNoteFromApId(uri); const note = await dbResolver.getNoteFromApId(uri);
@ -39,6 +37,6 @@ export default async function (
await deleteNode(actor, note); await deleteNode(actor, note);
return "ok: note deleted"; return "ok: note deleted";
} finally { } finally {
unlock(); await getApLock(uri);
} }
} }

View file

@ -415,8 +415,6 @@ export async function resolveNote(
`host ${extractDbHost(uri)} is blocked`, `host ${extractDbHost(uri)} is blocked`,
); );
const unlock = await getApLock(uri);
try { try {
//#region Returns if already registered with this server //#region Returns if already registered with this server
const exist = await fetchNote(uri); const exist = await fetchNote(uri);
@ -439,7 +437,7 @@ export async function resolveNote(
// Since the attached Note Object may be disguised, always specify the uri and fetch it from the server. // Since the attached Note Object may be disguised, always specify the uri and fetch it from the server.
return await createNote(uri, resolver, true); return await createNote(uri, resolver, true);
} finally { } finally {
unlock(); await getApLock(uri);
} }
} }

View file

@ -430,7 +430,6 @@ export default abstract class Chart<T extends Schema> {
? `${this.name}:${date}:${span}:${group}` ? `${this.name}:${date}:${span}:${group}`
: `${this.name}:${date}:${span}`; : `${this.name}:${date}:${span}`;
const unlock = await getChartInsertLock(lockKey);
try { try {
// ロック内でもう1回チェックする // ロック内でもう1回チェックする
const currentLog = (await repository.findOneBy({ const currentLog = (await repository.findOneBy({
@ -466,7 +465,7 @@ export default abstract class Chart<T extends Schema> {
return log; return log;
} finally { } finally {
unlock(); await getChartInsertLock(lockKey);
} }
} }