Skip to content

Commit

Permalink
list skipped items in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
cloverich committed Dec 9, 2024
1 parent 42ef2fc commit 52fa08c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/preload/client/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
validateJournalName,
} from "./journals";
import { IPreferencesClient } from "./preferences";
import { ISyncClient, SKIPPABLE_FILES, SKIPPABLE_PREFIXES } from "./sync";
import { ISyncClient } from "./sync";
import { SKIPPABLE_FILES, SKIPPABLE_PREFIXES } from "./types";

import * as mdast from "mdast";

Expand Down
21 changes: 6 additions & 15 deletions src/preload/client/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,14 @@ import { IDocumentsClient } from "./documents";
import { IFilesClient } from "./files";
import { IJournalsClient } from "./journals";
import { IPreferencesClient } from "./preferences";
import { GetDocumentResponse } from "./types";
import {
GetDocumentResponse,
SKIPPABLE_FILES,
SKIPPABLE_PREFIXES,
} from "./types";

export type ISyncClient = SyncClient;

// Nobody would put node_modules in their note directory... right?
// todo: Make this configurable
export const SKIPPABLE_FILES = new Set([
"node_modules",
"dist",
"build",
"out",
]);

// Skip hidden folders and files, especially .git, .DS_Store, .Thumbs.db, etc
// NOTE: This also skips _attachments, so add exclusion in importer routine
export const SKIPPABLE_PREFIXES = new Set([".", "_", "*", "~"]);

// Indicates which files to index when syncing
const shouldIndex = (dirent: fs.Dirent) => {
for (const prefix of SKIPPABLE_PREFIXES) {
Expand Down Expand Up @@ -70,7 +61,7 @@ updatedAt: ${document.updatedAt}
/**
* Sync the notes directory with the database
*/
sync = async (force = true) => {
sync = async (force = false) => {
// Skip sync if completed recently; not much thought put into this
const lastSync = await this.knex("sync").orderBy("id", "desc").first();
if (lastSync?.completedAt && !force) {
Expand Down
13 changes: 13 additions & 0 deletions src/preload/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,16 @@ export interface SaveRequest {
createdAt?: string;
updatedAt?: string;
}
// Nobody would put node_modules in their note directory... right?
// todo: Make this configurable

export const SKIPPABLE_FILES = new Set([
"node_modules",
"dist",
"build",
"out",
]);
// Skip hidden folders and files, especially .git, .DS_Store, .Thumbs.db, etc
// NOTE: This also skips _attachments, so add exclusion in importer routine

export const SKIPPABLE_PREFIXES = new Set([".", "_", "*", "~"]);
19 changes: 19 additions & 0 deletions src/views/preferences/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import useClient from "../../hooks/useClient";
import { useJournals } from "../../hooks/useJournals";
import { SourceType } from "../../preload/client/importer/SourceType";
import { Preferences } from "../../preload/client/preferences";
import {
SKIPPABLE_FILES,
SKIPPABLE_PREFIXES,
} from "../../preload/client/types";
import Titlebar from "../../titlebar/macos";
import * as Base from "../layout";

Expand Down Expand Up @@ -140,6 +144,21 @@ const Preferences = observer(() => {
<SettingsBox>
<h4>Import markdown directory</h4>
<p>Import a directory of markdown files. Experimental.</p>
<p>The following file / directory names will be skipped:</p>
<ul>
{Array.from(SKIPPABLE_FILES).map((file) => (
<li key={file}>{file}</li>
))}
</ul>
<p>
Other than _attachments, the following prefixes will cause a file or
directory to be skipped:
</p>
<ul>
{Array.from(SKIPPABLE_PREFIXES).map((prefix) => (
<li key={prefix}>{prefix}</li>
))}
</ul>

<Select
selected={store.sourceType}
Expand Down

0 comments on commit 52fa08c

Please sign in to comment.