https://bugs.kde.org/show_bug.cgi?id=524569

--- Comment #5 from [email protected] ---
I only have a github account not gitlab, but what do you think of this?

Disclaimer this was AI assisted and only a suggestion.  What are your thoughts
of the below code change?  I don't currently have a GitLab account, but I can
try making one.

``` cpp
if (pathItems.size() > 2) {
    const KMTPDeviceInterface *mtpDevice =
m_kmtpDaemon.deviceFromName(pathItems.first());
    if (mtpDevice) {
        const KMTPStorageInterface *storage =
mtpDevice->storageFromDescription(pathItems.at(1));
        if (storage) {
            const QString destinationPath = convertPath(url.path());

            // Check if the target path already exists on the MTP device
            const KMTPFile destinationFile =
storage->getFileMetadata(destinationPath);
            if (destinationFile.isValid()) {
                if (destinationFile.isFolder()) {
                    // Folder already exists; return pass so KIO can merge/step
into it
                    return WorkerResult::pass();
                } else {
                    // A regular file is blocking folder creation
                    return WorkerResult::fail(ERR_FILE_ALREADY_EXIST,
url.path());
                }
            }

            // Target is clear, proceed with folder creation
            const quint32 itemId = storage->createFolder(destinationPath);
            if (itemId) {
                return WorkerResult::pass();
            }
        }
    }
}
```

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to