Skip to content

Windows環境で.remoteディレクトリのファイルが記事一覧に混入するのを防ぐ - #428

Open
tahodev wants to merge 2 commits into
increments:mainfrom
tahodev:fix/remote-dir-filter-windows-separator
Open

tahodev wants to merge 2 commits into
increments:mainfrom
tahodev:fix/remote-dir-filter-windows-separator

Conversation

@tahodev

@tahodev tahodev commented Sep 29, 2026

Copy link
Copy Markdown

What

Windows 環境で .remote ディレクトリ内のファイルがローカルの記事・スライド一覧に混入するのを防ぎます。

How

fs.readdir(..., { recursive: true }) が返す相対パスの区切り文字は OS 依存(Windows では \)ですが、除外判定が filename.startsWith(".remote/") と / 固定でした。Windows では .remote\xxxx.md が除外されず、そのまま記事ファイルとして読み込まれていました。

先頭のパスセグメントで判定する isLocalMarkdownFilename を新設し、file-system-repo.ts と slide-file-system-repo.ts の両方のフィルタで使うようにしました。区切り文字の両方を網羅するテストを追加しています。

Why

Windows 環境で .remote のミラーがローカルの記事・スライドとして重複して扱われ、プレビュー一覧への混入や、記事 ID 検索時にミラー側が先にヒットするなどの誤動作につながるため。

Refs

@tsuzuki-takaaki tsuzuki-takaaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request ありがとうございます!確認が遅くなってすみません 🙏

コメントしたので、ご確認をお願いします!

Comment thread src/lib/file-system-repo.ts Outdated
).filter(
(itemFilename) =>
/\.md$/.test(itemFilename) && !itemFilename.startsWith(".remote/"),
/\.md$/.test(itemFilename) && isLocalMarkdownFilename(itemFilename),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

関数として切り出していただいた isLocalMarkdownFilename の中でも markdown ファイルかどうかの判定をしているので、こちらでの判定はなくても良さそうです!

Suggested change
/\.md$/.test(itemFilename) && isLocalMarkdownFilename(itemFilename),
isLocalMarkdownFilename(itemFilename),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.filter(isLocalMarkdownFilename)

のような感じで書けると良いかと思いました!

Comment thread src/lib/slide-file-system-repo.ts Outdated
)
).filter(
(filename) => /\.md$/.test(filename) && !filename.startsWith(".remote/"),
(filename) => /\.md$/.test(filename) && isLocalMarkdownFilename(filename),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらも同様にお願いしたいです!

https://github.com/increments/qiita-cli/pull/428/changes#r4164656008

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テスト名は、既存のテストに合わせて英語にしていただけると嬉しいです!

Comment thread src/lib/is-local-markdown-filename.ts Outdated
Comment on lines +1 to +2
// `fs.readdir(..., { recursive: true })` が返す相対パスの区切り文字は OS 依存のため、
// ".remote/" だけでなく ".remote\" (Windows) も除外できるように先頭セグメントで判定する。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このリポジトリでは、コードコメントは基本的に英語で書いているので、英語にしていただけると嬉しいです!

@tahodev

tahodev commented Oct 2, 2026

Copy link
Copy Markdown
Author

@tsuzuki-takaaki レビューありがとうございます!ご指摘の点を反映しました。

  • isLocalMarkdownFilename 内で .md 判定をしているため、file-system-repo.ts / slide-file-system-repo.ts では重複する判定を外し、.filter(isLocalMarkdownFilename) に変更
  • テスト名とコードコメントを英語に変更

jest src/lib は全て通っています。ご確認をお願いします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants