2025-07-16 20:32:43 +08:00

31 lines
957 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as SQLite from 'expo-sqlite';
const db = SQLite.openDatabaseSync('upload_status.db');
// 初始化表
export function initUploadTable() {
console.log('Initializing upload table...');
db.execSync(`
CREATE TABLE IF NOT EXISTS uploaded_files (
uri TEXT PRIMARY KEY NOT NULL
);
`);
console.log('Upload table initialized');
}
// 检查文件是否已上传 (使用同步API但保持接口为Promise以减少外部重构)
export async function isFileUploaded(uri: string): Promise<boolean> {
console.log('Checking if file is uploaded:', uri)
const result = db.getFirstSync<{ uri: string }>(
'SELECT uri FROM uploaded_files WHERE uri = ?;',
uri
);
console.log('File uploaded result:', result)
return !!result;
}
// 记录文件已上传
export function markFileAsUploaded(uri: string) {
db.runSync('INSERT OR IGNORE INTO uploaded_files (uri) VALUES (?);', uri);
}