@actions/io: `mv(file, dest)` replaces `dest` when it is a symlink to a directory instead of moving into it
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- devtools
調査の方向性
packages/io/src/io.tsを読み、mvが宛先がディレクトリかどうかをどのように確認するかを追ってください。その確認方法をio.cpおよびisDirectoryヘルパーのuseStatの動作と比較してください。ファイルをディレクトリへのsymlinkに移動する回帰テストを追加または更新し、その後symlinkが残り、ファイルが対象ディレクトリに現れることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
io.mv checks whether dest is a directory with ioUtil.isDirectory(dest), which uses lstat by default. When dest is a symlink pointing to a directory, isDirectory(dest) returns false and dest is treated as an existing file. With the default force: true, the symlink is deleted and the source is renamed to the symlink's path; with force: false, it throws "Destination already exists". By contrast, mv(1) (which @actions/io documents mv as following) and io.cp (which uses stat) move/copy the source into the target directory.
To Reproduce
Run the following with @actions/io:
// repro.mjs
import * as io from '@actions/io'
import fs from 'fs'
fs.mkdirSync('real-dir')
fs.symlinkSync('real-dir', 'link-dir')
fs.writeFileSync('a.txt', 'hello')
await io.mv('a.txt', 'link-dir')
console.log('link-dir is symlink:', fs.lstatSync('link-dir').isSymbolicLink())
console.log('real-dir:', fs.readdirSync('real-dir'))
mkdir demo && cd demo && node ../repro.mjs
Actual output:
link-dir is symlink: false
real-dir: []
(link-dir is now the moved file.)
Expected behavior
Matching mv a.txt link-dir (GNU coreutils 9.1) and io.cp:
link-dir is symlink: true
real-dir: [ 'a.txt' ]
Screenshots
N/A
Desktop (please complete the following information):
- OS: Linux (x86_64)
- Browser: N/A
- Version:
@actions/io3.0.2 (npm latest),actions/toolkitmain0c3a9c3, Node.js v26.13.0
Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
Additional context
In packages/io/src/io.ts, mv calls ioUtil.isDirectory(dest), whose useStat parameter defaults to false (lstat). Passing ioUtil.isDirectory(dest, true) would use stat and match io.cp and mv(1).
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 5.9k
- フォーク
- 1.8k
- 平均マージ
- 15分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
actions/toolkit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
@actions/exec: `exec(commandLine)` drops `""` arguments and trims trailing spaces of the last argument対応中かも @bardrop が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
actions/toolkit#2565 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
@actions/cache: downloadCacheHttpClientConcurrent never stops its progress timer on failure, so the step hangs until the job times out対応中かも @YodHeVauHe が 46 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
actions/toolkit の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
🛠️ dette technique
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
betagouv/mon-entreprise#4752 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
franciscoBSalgueiro/en-croissant#1111 ·
メンテナーはふだん 2 日以内に返信
-
area/providers type/feature version/v2
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
anomalyco/opencode#64845 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信