D28745: Skip caching thumbnails on encrypted filesystems

Marcin Gurtowski noreply at phabricator.kde.org
Mon Jun 29 11:31:17 BST 2020


marcingu added a comment.


  Ok, so far I have implemented `Solid::Device::storageAccessFromPath` by talking all StorageAccess devices, going though all of them and and returning proper one.
  code:
  
    Solid::Device Solid::Device::storageAccessFromPath(const QString &path)
    {
        // TODO check if symlinks are in the path
        QFileInfo fileInfo = QFileInfo(path);
        if (!fileInfo.exists()) {
            //TODO error handling
        }
        QSet<QString> checked; //To avoid weird infinete loops
        checked.insert(fileInfo.path());
        while (fileInfo.isSymLink()) {
            fileInfo = QFileInfo(fileInfo.symLinkTarget());
            if (checked.contains(fileInfo.path())) {
                //TODO error handling
            }
            checked.insert(fileInfo.path());
        }
        QDir dir = fileInfo.dir();
        QString canonPath = dir.canonicalPath();
        QList<Device> list = Solid::Device::listFromType(DeviceInterface::Type::StorageAccess);
        Device match;
        int match_length = 0;
        for (Device device: list) {
            StorageAccess *storageAccess = device.as<StorageAccess>();
            if (canonPath.startsWith(storageAccess->filePath()) && storageAccess->filePath().size() > match_length) {
                match_length = storageAccess->filePath().size();
                match = device;
            }
        }
        return match;
    }
  
  and in the thumbnail.cpp:
  
    Solid::Device device = Solid::Device::storageAccessFromPath(filePath);
    if (device.is<Solid::StorageVolume>()) {
        allowCache = device.as<Solid::StorageVolume>()->usage() != Solid::StorageVolume::UsageType::Encrypted;
    }
  
  It works, but it might be better to hold tree structure with all StorageAcces devices where position on tree would be determined by mountpoint of device, which would allow us to go straight to the desired StorageAccess without checking all of them.
  On the other hand, to do that we would have to slice path into parts and compare those parts with nodes on the tree and also create special structure for that. I'm not sure which approach is better.
  
  Another problem with storing StorageAccess tree is that I looked at DeviceManager classes and it might be too difficult for me, as I don't know Solid well.
  
  Which should it be and do we go about it?

REPOSITORY
  R320 KIO Extras

REVISION DETAIL
  https://phabricator.kde.org/D28745

To: marcingu, ivan, broulik, #dolphin, ngraham, meven, bruns
Cc: thiago, bruns, meven, ngraham, kde-frameworks-devel, kfm-devel, waitquietly, azyx, nikolaik, pberestov, iasensio, aprcela, fprice, LeGast00n, cblack, fbampaloukas, alexde, Codezela, feverfew, michaelh, spoorun, navarromorales, firef, andrebarros, emmanuelp, rdieter, mikesomov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20200629/08d0f1d7/attachment.htm>


More information about the kfm-devel mailing list