owncloud / android

:phone: The ownCloud Android App
GNU General Public License v2.0
3.77k stars 3.05k forks source link

[BUG] Conflict in copy: File without extension #4294

Closed Aitorbp closed 5 months ago

Aitorbp commented 5 months ago

Related Issues

App: https://github.com/owncloud/android/issues/4222

QA

Aitorbp commented 5 months ago

The startsWith function will not work with files that lack an extension for the following reason: If we have a file called test and we want to copy this same file to the same folder. The file will behave as follows:

“test (1)”.startsWith(“test”)

This function will return true and therefore enter the INVALID_COPY_INTO_DESCENDANT exception, since the prefix is the same.

The behavior with extension would be the following:

“test (1).log”.startsWith(“test.log”)

Thetest.log prefix is not contained in the target therefore it will return false. With a folder it has the same behavior, only instead of having an extension it has a slash / at the end.

I remove the startsWith condition from the CopyRemoteFileOperation class and keep this logic in the CopyFileUseCase, where these exceptions are being handled.

jesmrec commented 5 months ago

Fixed

jesmrec commented 5 months ago

Dont merge till https://github.com/owncloud/android/pull/4295 is also approved