Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
im-samwong opened this issue Mar 28, 2024 · 0 comments
Open

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

im-samwong opened this issue Mar 28, 2024 · 0 comments
Labels
Area-FileOperations Related to file operations (e.g. moving, copying, renaming). Issue-Bug Related unexpected behavior or something worth investigating.

Comments

@im-samwong
Copy link

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.

@VishnuSanal VishnuSanal added Area-FileOperations Related to file operations (e.g. moving, copying, renaming). Issue-Bug Related unexpected behavior or something worth investigating. labels Mar 29, 2024
@VishnuSanal VishnuSanal changed the title [Bug Report] Incorrect Copy Loop Detection Due to String contains Logic Incorrect Copy Loop Detection Due to String#contains Logic Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FileOperations Related to file operations (e.g. moving, copying, renaming). Issue-Bug Related unexpected behavior or something worth investigating.
Projects
None yet
Development

No branches or pull requests

2 participants