Skip to content

Commit

Permalink
fix: Ignore paths that begin with underscore (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin authored Jan 22, 2024
1 parent ccbf202 commit b5c979d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export default function (logger: Logger, db: MediaDatabase, config: Record<strin
.pipe(
concatMap(async ([mediaPath, mediaStat]) => {
const mediaId = getId(config.paths.media, mediaPath)

// Filter out files that are not to be scanned
if (!shouldFileBeScanned(mediaId, mediaPath)) return

try {
if (!mediaStat) {
await db.remove(await db.get(mediaId))
Expand Down Expand Up @@ -148,4 +152,16 @@ export default function (logger: Logger, db: MediaDatabase, config: Record<strin

mediaLogger.info('Scanned')
}
/**
* Filter out files that are not to be scanned
* @returns true if the media is to be scanned, false otherwise
*/
function shouldFileBeScanned(mediaId: string, _mediaPath: string): boolean {
if (mediaId.startsWith('_')) {
// PouchDB cannot store these ("Only reserved document ids may start with underscore.")
return false
}

return true
}
}

0 comments on commit b5c979d

Please sign in to comment.