一些检查失败了
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
27 行
819 B
TypeScript
27 行
819 B
TypeScript
import Logger from '@joplin/utils/Logger';
|
|
import Setting from '@joplin/lib/models/Setting';
|
|
import shim from '@joplin/lib/shim';
|
|
|
|
export const autosaveFilename = 'autosaved-drawing.joplin.svg';
|
|
|
|
const logger = Logger.create('ImageEditor/autosave');
|
|
|
|
export const getAutosaveFilepath = () => {
|
|
return `${Setting.value('resourceDir')}/${autosaveFilename}`;
|
|
};
|
|
|
|
export const writeAutosave = async (data: string) => {
|
|
const filePath = getAutosaveFilepath();
|
|
logger.info(`Auto-saving drawing to ${JSON.stringify(filePath)}`);
|
|
|
|
await shim.fsDriver().writeFile(filePath, data, 'utf8');
|
|
};
|
|
|
|
export const readAutosave = async (): Promise<string|null> => {
|
|
return await shim.fsDriver().readFile(getAutosaveFilepath());
|
|
};
|
|
|
|
export const clearAutosave = async () => {
|
|
await shim.fsDriver().remove(getAutosaveFilepath());
|
|
};
|