| 96 | |
| 97 | |
| 98 | def init_db(remove_exists=False): |
| 99 | cache_folder = os.path.join(os.path.expanduser("~"), ".cache", "pdf2zh") |
| 100 | os.makedirs(cache_folder, exist_ok=True) |
| 101 | # The current version does not support database migration, so add the version number to the file name. |
| 102 | cache_db_path = os.path.join(cache_folder, "cache.v1.db") |
| 103 | if remove_exists and os.path.exists(cache_db_path): |
| 104 | os.remove(cache_db_path) |
| 105 | db.init( |
| 106 | cache_db_path, |
| 107 | pragmas={ |
| 108 | "journal_mode": "wal", |
| 109 | "busy_timeout": 1000, |
| 110 | }, |
| 111 | ) |
| 112 | db.create_tables([_TranslationCache], safe=True) |
| 113 | |
| 114 | |
| 115 | def init_test_db(): |