Incorrect Copy Loop Detection Due to `String#contains` Logic

オープン 初心者向け
#4,131 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
android, java
領域
mobile, testing

調査の方向性

app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java とエントリーポイント isCopyLoopPossible から始めます。/documents/work や /documents/workk のような、互いに重複しない類似のパスを使って、示されている単体テストを実行または拡張します。このケースでメソッドが false を返せば完了です。

索引モデルが issue の本文から書いたものです。

説明

Area-FileOperations Issue-Bug

Summary:
The isCopyLoopPossible method incorrectly identifies a copy loop for similar but non-overlapping directory paths due to reliance on string contains logic. Located at app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java

To Reproduce
Steps to reproduce the behavior:

  1. Invoke the isCopyLoopPossible method programmatically within the app, passing a source file path and a target file path where the target path is similar but not actually a subdirectory of the source (e.g., /documents/work and /documents/workk).
  2. Observe the method's return value.

Expected behavior
The method should return false, indicating no copy loop is possible because the target directory is not a subdirectory of the source directory.

Actual Outcome
The method returns true, incorrectly suggesting a copy loop is possible due to the similarity of the paths.

Screenshots
For this unit test:

  @Test
  public void testIsCopyLoopPossibleWithSimilarButNonOverlappingPaths() {
      HybridFileParcelable sourceFile = new HybridFileParcelable("/documents/work");
      HybridFile targetFile = new HybridFile(OpenMode.FILE, "/documents/workk");

      assertFalse("Copy loop should not be detected for similar but non-overlapping paths",
                Operations.isCopyLoopPossible(sourceFile, targetFile));
  }

bug

Smartphone (please complete the following information):
N/A

Additional context
There was no GUI error. Tried reproducing error on small scale on GUI with android emulator and no issues. Although, when trying to copy parent directory into subdirectory of itself, it copied over just empty directory. Could cause problems on a larger scale.

主要言語
Kotlin
スター
6.5k
フォーク
1.7k
平均マージ
9日 21時間
マージ済み PR(30日)
7

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TeamAmaze/AmazeFileManager のほかの issue

TeamAmaze/AmazeFileManager の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。