diff --git a/src/lib/deltas.ts b/src/lib/deltas.ts index 5edc2ae..2294921 100644 --- a/src/lib/deltas.ts +++ b/src/lib/deltas.ts @@ -494,6 +494,7 @@ export class Deltas { .sort((a, b) => a.path.split("/").length - b.path.split("/").length) // Filter by ignored paths .filter(delta => { + const trailingSlash = delta.type.endsWith("Directory") ? "/" : "" if ( delta.type === "renameLocalDirectory" || delta.type === "renameLocalFile" || @@ -504,7 +505,7 @@ export class Deltas { return false } - if (this.sync.ignorer.ignores(delta.from) || this.sync.ignorer.ignores(delta.to)) { + if (this.sync.ignorer.ignores(delta.from + trailingSlash) || this.sync.ignorer.ignores(delta.to + trailingSlash)) { return false } } else { @@ -512,7 +513,7 @@ export class Deltas { return false } - if (this.sync.ignorer.ignores(delta.path)) { + if (this.sync.ignorer.ignores(delta.path + trailingSlash)) { return false } } diff --git a/src/lib/filesystems/local.ts b/src/lib/filesystems/local.ts index 6d5394a..02b6dd9 100644 --- a/src/lib/filesystems/local.ts +++ b/src/lib/filesystems/local.ts @@ -120,7 +120,8 @@ export class LocalFileSystem { public isPathIgnored( relativePath: string, - absolutePath: string + absolutePath: string, + type: "file" | "directory" ): { ignored: true; reason: LocalTreeIgnoredReason } | { ignored: false } { if (this.ignoredCache.get(relativePath)) { return this.ignoredCache.get(relativePath)! @@ -186,7 +187,8 @@ export class LocalFileSystem { } } - if (this.sync.ignorer.ignores(relativePath)) { + const trailingSlash = type === "directory" ? "/" : "" + if (this.sync.ignorer.ignores(relativePath + trailingSlash)) { this.ignoredCache.set(relativePath, { ignored: true, reason: "filenIgnore" @@ -316,27 +318,27 @@ export class LocalFileSystem { pathsAdded[lowercasePath] = true - const ignored = this.isPathIgnored(entryItem, absolutePath) + let stats: fs.Stats | null = null - if (ignored.ignored) { + try { + stats = await fs.stat(absolutePath) + } catch { this.getDirectoryTreeCache.ignored.push({ localPath: absolutePath, relativePath: entryPath, - reason: ignored.reason + reason: "permissions" }) continue } - let stats: fs.Stats | null = null + const ignored = this.isPathIgnored(entryItem, absolutePath, stats.isFile() ? "file" : "directory") - try { - stats = await fs.stat(absolutePath) - } catch { + if (ignored.ignored) { this.getDirectoryTreeCache.ignored.push({ localPath: absolutePath, relativePath: entryPath, - reason: "permissions" + reason: ignored.reason }) continue diff --git a/src/lib/filesystems/remote.ts b/src/lib/filesystems/remote.ts index fd783eb..77a83e2 100644 --- a/src/lib/filesystems/remote.ts +++ b/src/lib/filesystems/remote.ts @@ -184,7 +184,8 @@ export class RemoteFileSystem { } } - if (this.sync.ignorer.ignores(relativePath)) { + const trailingSlash = type === "directory" ? "/" : "" + if (this.sync.ignorer.ignores(relativePath + trailingSlash)) { this.ignoredCache.set(key, { ignored: true, reason: "filenIgnore"