Skip to content

Commit

Permalink
fix: better default ignore logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Nov 22, 2024
1 parent 526074b commit e5724f5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@filen/sync",
"version": "0.1.81",
"version": "0.1.82",
"description": "Filen Sync",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -54,7 +54,7 @@
"wait-on": "^7.2.0"
},
"dependencies": {
"@filen/sdk": "^0.1.181",
"@filen/sdk": "^0.1.182",
"@parcel/watcher": "^2.5.0",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DEFAULT_IGNORED = {
"COM8",
"COM9"
],
extensions: [".tmp", ".temp", ".ffs_tmp", ".temporary", ".crdownload", ".~cr", ".thumbdata"],
extensions: [".tmp", ".temp", ".ffs_tmp", ".temporary", ".crdownload", ".~cr", ".thumbdata", ".crswap"],
absoluteGlobs: [
"*:/$WINDOWS.~BT/**/*",
"*:/$RECYCLE.BIN/**/*",
Expand All @@ -47,7 +47,7 @@ export const DEFAULT_IGNORED = {
"*:/Program Files/**/*",
"*:/Program Files (x86)/**/*",
"/share/Trash/**/*",
"*:/Users/*/AppData/**/*",
"*:/Users/**/AppData/**/*",
"*:/System Volume Information/**/*"
],
relativeGlobs: [
Expand Down
2 changes: 2 additions & 0 deletions src/ignorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Ignorer {
private sync: Sync
public instance = ignore()
public name: string = "ignorer"
public pattern: string[] = []

public constructor(sync: Sync, name: string = "ignorer") {
this.sync = sync
Expand Down Expand Up @@ -63,6 +64,7 @@ export class Ignorer {
content = (await this.fetch()).split("\n").map(line => line.trim())
}

this.pattern = content
this.instance = ignore()

if (content.length > 0) {
Expand Down
14 changes: 12 additions & 2 deletions src/lib/filesystems/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import pathModule from "path"
import process from "process"
import type Sync from "../sync"
import { SYNC_INTERVAL, LOCAL_TRASH_NAME } from "../../constants"
import { SYNC_INTERVAL, LOCAL_TRASH_NAME, DEFAULT_IGNORED } from "../../constants"
import crypto from "crypto"
import { pipeline } from "stream"
import { promisify } from "util"
Expand Down Expand Up @@ -253,7 +253,17 @@ export class LocalFileSystem {
followSymbolicLinks: false,
deep: Infinity,
fs,
ignore: [".filen.trash.local/**/*", "$RECYCLE.BIN/**/*", "System Volume Information/**/*"],
ignore: [
"**/.filen.trash.local/**/*",
"**/$RECYCLE.BIN/**/*",
"**/System Volume Information/**/*",
...DEFAULT_IGNORED.relativeGlobs.map(glob => `**/${glob}`),
...DEFAULT_IGNORED.absoluteGlobs.map(glob => {
const normalized = glob.replace("*:", "")

return `**${normalized.startsWith("/") ? "" : "/"}${normalized}`
})
],
suppressErrors: false,
stats: true,
unique: false,
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import micromatch from "micromatch"
* @param {number} [chunkSize=10000]
* @returns {Promise<T[]>}
*/
export async function promiseAllChunked<T>(promises: Promise<T>[], chunkSize = 100000): Promise<T[]> {
export async function promiseAllChunked<T>(promises: Promise<T>[], chunkSize = 10000): Promise<T[]> {
const results: T[] = []

for (let i = 0; i < promises.length; i += chunkSize) {
Expand All @@ -35,10 +35,10 @@ export async function promiseAllChunked<T>(promises: Promise<T>[], chunkSize = 1
* @async
* @template T
* @param {Promise<T>[]} promises
* @param {number} [chunkSize=100000]
* @param {number} [chunkSize=10000]
* @returns {Promise<T[]>}
*/
export async function promiseAllSettledChunked<T>(promises: Promise<T>[], chunkSize = 100000): Promise<T[]> {
export async function promiseAllSettledChunked<T>(promises: Promise<T>[], chunkSize = 10000): Promise<T[]> {
const results: T[] = []

for (let i = 0; i < promises.length; i += chunkSize) {
Expand Down

0 comments on commit e5724f5

Please sign in to comment.