Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion PeerCouchDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { decodeBinary } from "./lib/src/string_and_binary/convert.ts";
import { isPlainText } from "./lib/src/string_and_binary/path.ts";
import { DispatchFun, Peer } from "./Peer.ts";
import { createBinaryBlob, createTextBlob, isDocContentSame, unique } from "./lib/src/common/utils.ts";
import { minimatch } from "minimatch";

// export class PeerInstance()

Expand Down Expand Up @@ -156,6 +157,9 @@ export class PeerCouchDB extends Peer {
if (path.startsWith("/")) {
path = path.substring(1);
}
if (path.startsWith("i:")) {
path = path.substring(2);
}
if (entry.deleted || entry._deleted) {
this.sendLog(`${path} delete detected`);
await this.dispatchDeleted(path);
Expand All @@ -166,7 +170,13 @@ export class PeerCouchDB extends Peer {
}
}, (entry) => {
this.setSetting("since", this.man.since);
if (entry.path.indexOf(":") !== -1) return false;
if (entry.path.indexOf(":") !== -1) {
if (this.config.includeInternal && entry.path.startsWith("i:")) {
const stripped = entry.path.substring(2);
return this.config.includeInternal.some(pattern => minimatch(stripped, pattern, { dot: true }));
}
return false;
}
return entry.path.startsWith(baseDir);
});
}
Expand Down
2 changes: 2 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface PeerStorageConf {
useChokidar?: boolean;
}
export interface PeerCouchDBConf extends DirectFileManipulatorOptions {
/** Glob patterns for i:-prefixed (internal) files to sync, e.g. [".claude/**"] */
includeInternal?: string[];
type: "couchdb";
useRemoteTweaks?: true;
group?: string;
Expand Down