mirror of
https://github.com/heroblackink/ultimate-todoist-sync-for-obsidian.git
synced 2026-07-22 07:40:27 +00:00
fix: use dynamic plugin directory path for settings file (fixes #108)
This commit is contained in:
parent
b0285ad8f2
commit
0f59756a13
5 changed files with 21 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "ultimate-todoist-sync",
|
||||
"name": "Ultimate Todoist Sync",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"minAppVersion": "1.0.0",
|
||||
"description": "This is the best Todoist task synchronization plugin for Obsidian so far.",
|
||||
"author": "HeroBlackInk",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ultimate-todoist-sync",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -289,8 +289,8 @@ export class SafeSettings {
|
|||
this.cancelDebouncedSave();
|
||||
|
||||
return this.withSettingsIOLock('save', async () => {
|
||||
const settingsPath = StoragePathManager.SETTINGS_FILE;
|
||||
const tempPath = StoragePathManager.SETTINGS_TEMP_FILE;
|
||||
const settingsPath = this.plugin.storagePathManager!.settingsFilePath;
|
||||
const tempPath = this.plugin.storagePathManager!.settingsTempFilePath;
|
||||
|
||||
try {
|
||||
if (!this.plugin.settings || Object.keys(this.plugin.settings).length === 0) {
|
||||
|
|
@ -599,7 +599,7 @@ export class SettingsBackup {
|
|||
return this.withSettingsIOLock('backup', async () => {
|
||||
try {
|
||||
await this.ensureBackupDir();
|
||||
const settingsPath = StoragePathManager.SETTINGS_FILE;
|
||||
const settingsPath = this.plugin.storagePathManager!.settingsFilePath;
|
||||
const adapter = this.app.vault.adapter;
|
||||
const exists = await adapter.exists(settingsPath);
|
||||
if (!exists) {
|
||||
|
|
@ -652,8 +652,8 @@ export class SettingsBackup {
|
|||
new Notice('Backup file is corrupted, cannot restore');
|
||||
return false;
|
||||
}
|
||||
const settingsPath = StoragePathManager.SETTINGS_FILE;
|
||||
const tempPath = StoragePathManager.SETTINGS_TEMP_FILE;
|
||||
const settingsPath = this.plugin.storagePathManager!.settingsFilePath;
|
||||
const tempPath = this.plugin.storagePathManager!.settingsTempFilePath;
|
||||
await adapter.write(tempPath, data);
|
||||
await adapter.write(settingsPath, data);
|
||||
await adapter.remove(tempPath).catch(() => {});
|
||||
|
|
@ -703,8 +703,8 @@ export class SettingsBackup {
|
|||
new Notice('Backup file is corrupted');
|
||||
return false;
|
||||
}
|
||||
const settingsPath = StoragePathManager.SETTINGS_FILE;
|
||||
const tempPath = StoragePathManager.SETTINGS_TEMP_FILE;
|
||||
const settingsPath = this.plugin.storagePathManager!.settingsFilePath;
|
||||
const tempPath = this.plugin.storagePathManager!.settingsTempFilePath;
|
||||
await adapter.write(tempPath, data);
|
||||
await adapter.write(settingsPath, data);
|
||||
await adapter.remove(tempPath).catch(() => {});
|
||||
|
|
@ -722,8 +722,8 @@ export class SettingsBackup {
|
|||
async recoverFromTempFile(): Promise<boolean> {
|
||||
return this.withSettingsIOLock('recover-temp', async () => {
|
||||
try {
|
||||
const tempPath = StoragePathManager.SETTINGS_TEMP_FILE;
|
||||
const settingsPath = StoragePathManager.SETTINGS_FILE;
|
||||
const tempPath = this.plugin.storagePathManager!.settingsTempFilePath;
|
||||
const settingsPath = this.plugin.storagePathManager!.settingsFilePath;
|
||||
const adapter = this.app.vault.adapter;
|
||||
if (!await adapter.exists(tempPath)) return false;
|
||||
const data = await adapter.read(tempPath);
|
||||
|
|
@ -752,7 +752,7 @@ export class SettingsBackup {
|
|||
}
|
||||
|
||||
async hasTempFile(): Promise<boolean> {
|
||||
return this.app.vault.adapter.exists(StoragePathManager.SETTINGS_TEMP_FILE);
|
||||
return this.app.vault.adapter.exists(this.plugin.storagePathManager!.settingsTempFilePath);
|
||||
}
|
||||
|
||||
async clearAllBackups(): Promise<boolean> {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,13 @@ export class StoragePathManager {
|
|||
private plugin: UltimateTodoistSyncForObsidian;
|
||||
private appendLock = false;
|
||||
|
||||
static readonly SETTINGS_FILE = '.obsidian/plugins/ultimate-todoist-sync-for-obsidian/data.json';
|
||||
static readonly SETTINGS_TEMP_FILE = '.obsidian/plugins/ultimate-todoist-sync-for-obsidian/data.json.tmp';
|
||||
get settingsFilePath(): string {
|
||||
return `${this.plugin.manifest.dir}/data.json`;
|
||||
}
|
||||
|
||||
get settingsTempFilePath(): string {
|
||||
return `${this.plugin.manifest.dir}/data.json.tmp`;
|
||||
}
|
||||
static readonly DEFAULT_BASE_PATH = 'ultimate-todoist-sync';
|
||||
static readonly LEGACY_BASE_PATH = '.ultimate-todoist-sync';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"1.0.0": "0.15.0",
|
||||
"2.0.0": "1.0.0"
|
||||
"2.0.0": "1.0.0",
|
||||
"2.0.1": "1.0.0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue