Skip to content

Tankōbon / main/db/path-roots / PathRoots

Class: PathRoots ​

Defined in: main/db/path-roots.ts:81

The library folders as this machine sees them. The database keeps a book under a folder as root:<id>/<path relative to the folder> (forward slashes, whatever the OS), and each machine says where folder <id> is, so a library on a shared drive, a cloud folder or a network share opens from any path. A book outside every folder keeps its absolute path.

The mapping is also what the codec uses: encode() picks the deepest folder that contains the file, decode() joins the folder's path here with the relative part. A stored path whose folder has no path on this machine decodes to itself, which no file matches (the book reads as missing until the folder is relinked), and encodes back to itself.

Implements ​

Constructors ​

Constructor ​

new PathRoots(store?): PathRoots

Defined in: main/db/path-roots.ts:84

Parameters ​

store? ​

RootsStore = ...

Returns ​

PathRoots

Methods ​

decode() ​

decode(stored): string

Defined in: main/db/path-roots.ts:112

The absolute path, on this machine, of a stored path.

Parameters ​

stored ​

string

Returns ​

string

Implementation of ​

PathCodec.decode


encode() ​

encode(filePath): string

Defined in: main/db/path-roots.ts:99

The form to store (and compare in SQL) for the absolute path filePath.

Parameters ​

filePath ​

string

Returns ​

string

Implementation of ​

PathCodec.encode


get() ​

get(id): string | undefined

Defined in: main/db/path-roots.ts:89

This machine's path of folder id, or undefined when it has none.

Parameters ​

id ​

string

Returns ​

string | undefined


set() ​

set(id, folderPath): void

Defined in: main/db/path-roots.ts:94

Says where folder id is on this machine, and remembers it.

Parameters ​

id ​

string

folderPath ​

string

Returns ​

void