Skip to content

Deletes all content from DiskSahre on empty folder name #756

@Redwid

Description

@Redwid

Seen that behaviour twice already.
I've code to delete folder from DiskShare.
But if I'm open DiskEntry with empty file path and then will call rmDir(), library deletes all files from that DiskShare.

Kotlin Code:

val share: DiskShare = session?.connectShare(FOLDER_MEDIA) as DiskShare
var diskEntry: DiskEntry? = null
try {
    assertIsSafeToDelete(path)
    diskEntry = share.open(
        "",
        EnumSet.of(AccessMask.FILE_DELETE_CHILD),
        EnumSet.of(FileAttributes.FILE_ATTRIBUTE_DIRECTORY),
        SMB2ShareAccess.ALL,
        SMB2CreateDisposition.FILE_OPEN,
        Collections.singleton(SMB2CreateOptions.FILE_DIRECTORY_FILE)
    )
    diskEntry.diskShare.rmdir(path, true)
    Timber.d("deleteFile(), diskEntry: %s", diskEntry)
}  finally {
    closeSafely(diskEntry)
}

I'm expecting exception here on share.open() as object not exists ... or something similar.
Or fail of rmDir() call. But definitely not delete all.

Library version: 0.11.5
Samba version: 4.15.13-Ubuntu
Server version: Ubuntu 22.04.1
User has read-write permission

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions