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

Aperta Adatta ai principianti
#4,131 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 7 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
android, java
Ambito
mobile, testing

Direzione di ricerca

Inizia da app/src/test/java/com/amaze/filemanager/filesystem/OperationsTest.java e dall’entry point isCopyLoopPossible. Esegui o estendi lo unit test mostrato usando percorsi simili e non sovrapposti, come /documents/work e /documents/workk; il lavoro è completato quando il metodo restituisce false per questo caso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Kotlin
Stelle
6.5k
Fork
1.7k
Merge medio
9g 21h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TeamAmaze/AmazeFileManager

Tutte le issue di TeamAmaze/AmazeFileManager

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.