TeamAmaze / TeamAmaze/AmazeFileManager

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

Open Beginner friendly
#4,131 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-FileOperations Issue-Bug
Dominant language
Kotlin
Stars
6.4k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java and the isCopyLoopPossible entry point. Run or extend the shown unit test using similar, non-overlapping paths such as /documents/work and /documents/workk; done means the method returns false for that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.