feat: Automatic plaintext backup option in Preferences > Backups will backup your notes and tags into plaintext, unencrypted folders on your computer. In addition, automatic encrypted text backups preference management has moved from the top-level menu in the desktop app to Preferences > Backups. (#2322)

This commit is contained in:
Mo
2023-05-02 11:05:10 -05:00
committed by GitHub
parent 3df23cdb5c
commit 7e3db49322
76 changed files with 1526 additions and 1013 deletions

View File

@@ -0,0 +1,8 @@
export type DesktopWatchedDirectoriesChange = {
itemUuid: string
path: string
type: 'rename' | 'change'
content: string
}
export type DesktopWatchedDirectoriesChanges = DesktopWatchedDirectoriesChange[]

View File

@@ -1,12 +1,44 @@
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
import { FileBackupRecord, FileBackupsMapping } from './FileBackupsMapping'
import { FileBackupsMapping } from './FileBackupsMapping'
type PlaintextNoteRecord = {
tag?: string
path: string
}
type UuidString = string
export type PlaintextBackupsMapping = {
version: string
files: Record<UuidString, PlaintextNoteRecord[]>
}
export interface FileBackupsDevice
extends FileBackupsMethods,
LegacyBackupsMethods,
PlaintextBackupsMethods,
TextBackupsMethods {
openLocation(path: string): Promise<void>
/**
* The reason we combine presenting a directory picker and transfering old files to the new location
* in one function is so we don't have to expose a general `transferDirectories` function to the web app,
* which would give it too much power.
* @param appendPath The path to append to the selected directory.
*/
presentDirectoryPickerForLocationChangeAndTransferOld(
appendPath: string,
oldLocation?: string,
): Promise<string | undefined>
monitorPlaintextBackupsLocationForChanges(backupsDirectory: string): Promise<void>
}
export type FileBackupReadToken = string
export type FileBackupReadChunkResponse = { chunk: Uint8Array; isLast: boolean; progress: FileDownloadProgress }
export interface FileBackupsDevice {
getFilesBackupsMappingFile(): Promise<FileBackupsMapping>
interface FileBackupsMethods {
getFilesBackupsMappingFile(location: string): Promise<FileBackupsMapping>
saveFilesBackupsFile(
location: string,
uuid: string,
metaFile: string,
downloadRequest: {
@@ -15,13 +47,26 @@ export interface FileBackupsDevice {
url: string
},
): Promise<'success' | 'failed'>
getFileBackupReadToken(record: FileBackupRecord): Promise<FileBackupReadToken>
getFileBackupReadToken(filePath: string): Promise<FileBackupReadToken>
readNextChunk(token: string): Promise<FileBackupReadChunkResponse>
isFilesBackupsEnabled(): Promise<boolean>
enableFilesBackups(): Promise<void>
disableFilesBackups(): Promise<void>
changeFilesBackupsLocation(): Promise<string | undefined>
getFilesBackupsLocation(): Promise<string>
openFilesBackupsLocation(): Promise<void>
openFileBackup(record: FileBackupRecord): Promise<void>
}
interface PlaintextBackupsMethods {
getPlaintextBackupsMappingFile(location: string): Promise<PlaintextBackupsMapping>
persistPlaintextBackupsMappingFile(location: string): Promise<void>
savePlaintextNoteBackup(location: string, uuid: string, name: string, tags: string[], data: string): Promise<void>
}
interface TextBackupsMethods {
getTextBackupsCount(location: string): Promise<number>
saveTextBackupData(location: string, data: string): Promise<void>
getUserDocumentsDirectory(): Promise<string>
}
interface LegacyBackupsMethods {
migrateLegacyFileBackupsToNewStructure(newPath: string): Promise<void>
isLegacyFilesBackupsEnabled(): Promise<boolean>
getLegacyFilesBackupsLocation(): Promise<string | undefined>
wasLegacyTextBackupsExplicitlyDisabled(): Promise<boolean>
getLegacyTextBackupsLocation(): Promise<string | undefined>
}

View File

@@ -2,7 +2,6 @@ import { FileBackupsConstantsV1 } from './FileBackupsConstantsV1'
export type FileBackupRecord = {
backedUpOn: Date
absolutePath: string
relativePath: string
metadataFileName: typeof FileBackupsConstantsV1.MetadataFileName
binaryFileName: typeof FileBackupsConstantsV1.BinaryFileName