一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
50 行
1.3 KiB
TypeScript
50 行
1.3 KiB
TypeScript
import JoplinDatabase from '../../JoplinDatabase';
|
|
import BaseItem from '../../models/BaseItem';
|
|
import Setting from '../../models/Setting';
|
|
import SyncTargetRegistry from '../../SyncTargetRegistry';
|
|
import { SqlQuery } from '../database/types';
|
|
|
|
async function clearSyncContext() {
|
|
const syncTargetIds = SyncTargetRegistry.allIds();
|
|
|
|
for (const syncTargetId of syncTargetIds) {
|
|
const key = `sync.${syncTargetId}.context`;
|
|
if (Setting.keyExists(key)) {
|
|
Setting.resetKey(key);
|
|
}
|
|
}
|
|
|
|
await Setting.saveAll();
|
|
}
|
|
|
|
export async function clearLocalSyncStateForReupload(db: JoplinDatabase) {
|
|
const queries: SqlQuery[] = [
|
|
{ sql: 'DELETE FROM deleted_items' },
|
|
{ sql: 'DELETE FROM sync_items' },
|
|
];
|
|
|
|
await db.transactionExecBatch(queries);
|
|
|
|
await clearSyncContext();
|
|
}
|
|
|
|
export async function clearLocalDataForRedownload(db: JoplinDatabase) {
|
|
const queries: SqlQuery[] = [
|
|
{ sql: 'DELETE FROM deleted_items' },
|
|
{ sql: 'DELETE FROM sync_items' },
|
|
{ sql: 'DELETE FROM item_changes' },
|
|
{ sql: 'DELETE FROM note_resources' },
|
|
];
|
|
|
|
const syncItemTypes = BaseItem.syncItemTypes();
|
|
|
|
for (const syncItemType of syncItemTypes) {
|
|
const SyncItemClass = BaseItem.getClassByItemType(syncItemType);
|
|
queries.push({ sql: `DELETE FROM ${db.escapeField(SyncItemClass.tableName())}` });
|
|
}
|
|
|
|
await db.transactionExecBatch(queries);
|
|
|
|
await clearSyncContext();
|
|
}
|