Changeset View
Changeset View
Standalone View
Standalone View
src/kio_gdrive.cpp
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | |||||
139 | void KIOGDrive::fileSystemFreeSpace(const QUrl &url) | 139 | void KIOGDrive::fileSystemFreeSpace(const QUrl &url) | ||
140 | { | 140 | { | ||
141 | const auto gdriveUrl = GDriveUrl(url); | 141 | const auto gdriveUrl = GDriveUrl(url); | ||
142 | const QString accountId = gdriveUrl.account(); | 142 | const QString accountId = gdriveUrl.account(); | ||
143 | if (accountId == QLatin1String("new-account")) { | 143 | if (accountId == QLatin1String("new-account")) { | ||
144 | finished(); | 144 | finished(); | ||
145 | return; | 145 | return; | ||
146 | } | 146 | } | ||
147 | if (!gdriveUrl.isRoot()) { | 147 | if (gdriveUrl.isRoot()) { | ||
148 | qCDebug(GDRIVE) << "Can't fileSystemFreeSpace for root"; | ||||
elvisangelaccio: This message is a bit cryptic. How about "fileSystemFreeSpace is not supported for gdrive root… | |||||
149 | error(KIO::ERR_CANNOT_STAT, url.toDisplayString()); | ||||
150 | return; | ||||
151 | } | ||||
152 | | ||||
148 | AboutFetchJob aboutFetch(getAccount(accountId)); | 153 | AboutFetchJob aboutFetch(getAccount(accountId)); | ||
149 | aboutFetch.setFields({ | 154 | aboutFetch.setFields({ | ||
150 | About::Fields::Kind, | 155 | About::Fields::Kind, | ||
151 | About::Fields::QuotaBytesTotal, | 156 | About::Fields::QuotaBytesTotal, | ||
152 | About::Fields::QuotaBytesUsedAggregate | 157 | About::Fields::QuotaBytesUsedAggregate | ||
153 | }); | 158 | }); | ||
154 | if (runJob(aboutFetch, url, accountId)) { | 159 | if (runJob(aboutFetch, url, accountId)) { | ||
155 | const AboutPtr about = aboutFetch.aboutData(); | 160 | const AboutPtr about = aboutFetch.aboutData(); | ||
156 | if (about) { | 161 | if (about) { | ||
157 | setMetaData(QStringLiteral("total"), QString::number(about->quotaBytesTotal())); | 162 | setMetaData(QStringLiteral("total"), QString::number(about->quotaBytesTotal())); | ||
158 | setMetaData(QStringLiteral("available"), QString::number(about->quotaBytesTotal() - about->quotaBytesUsedAggregate())); | 163 | setMetaData(QStringLiteral("available"), QString::number(about->quotaBytesTotal() - about->quotaBytesUsedAggregate())); | ||
159 | finished(); | 164 | finished(); | ||
160 | return; | 165 | return; | ||
161 | } | 166 | } | ||
162 | } | 167 | } | ||
163 | } | 168 | } | ||
164 | error(KIO::ERR_CANNOT_STAT, url.toDisplayString()); | | |||
165 | } | | |||
166 | 169 | | |||
167 | AccountPtr KIOGDrive::getAccount(const QString &accountName) | 170 | AccountPtr KIOGDrive::getAccount(const QString &accountName) | ||
168 | { | 171 | { | ||
169 | return m_accountManager->account(accountName); | 172 | return m_accountManager->account(accountName); | ||
170 | } | 173 | } | ||
171 | 174 | | |||
172 | void KIOGDrive::virtual_hook(int id, void *data) | 175 | void KIOGDrive::virtual_hook(int id, void *data) | ||
173 | { | 176 | { | ||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Line(s) | 434 | { | |||
461 | query.addQuery(FileSearchQuery::Parents, FileSearchQuery::In, folderId); | 464 | query.addQuery(FileSearchQuery::Parents, FileSearchQuery::In, folderId); | ||
462 | FileFetchJob fileFetchJob(query, getAccount(accountId)); | 465 | FileFetchJob fileFetchJob(query, getAccount(accountId)); | ||
463 | const auto extraFields = | 466 | const auto extraFields = | ||
464 | QStringList({ KGAPI2::Drive::File::Fields::Labels, | 467 | QStringList({ KGAPI2::Drive::File::Fields::Labels, | ||
465 | KGAPI2::Drive::File::Fields::ExportLinks, | 468 | KGAPI2::Drive::File::Fields::ExportLinks, | ||
466 | KGAPI2::Drive::File::Fields::LastViewedByMeDate, | 469 | KGAPI2::Drive::File::Fields::LastViewedByMeDate, | ||
467 | }); | 470 | }); | ||
468 | fileFetchJob.setFields(KGAPI2::Drive::FileFetchJob::FieldShorthands::BasicFields + extraFields); | 471 | fileFetchJob.setFields(KGAPI2::Drive::FileFetchJob::FieldShorthands::BasicFields + extraFields); | ||
469 | runJob(fileFetchJob, url, accountId); | 472 | if (!runJob(fileFetchJob, url, accountId)) { | ||
473 | // runJob called error() | ||||
Please move this comment in the runJob() doxygen comment in kio_gdrive.h, rather than duplicating it here n times. elvisangelaccio: Please move this comment in the `runJob()` doxygen comment in kio_gdrive.h, rather than… | |||||
474 | return; | ||||
475 | } | ||||
470 | 476 | | |||
471 | ObjectsList objects = fileFetchJob.items(); | 477 | ObjectsList objects = fileFetchJob.items(); | ||
472 | Q_FOREACH (const ObjectPtr &object, objects) { | 478 | Q_FOREACH (const ObjectPtr &object, objects) { | ||
473 | const FilePtr file = object.dynamicCast<File>(); | 479 | const FilePtr file = object.dynamicCast<File>(); | ||
474 | 480 | | |||
475 | const KIO::UDSEntry entry = fileToUDSEntry(file, url.adjusted(QUrl::StripTrailingSlash).path()); | 481 | const KIO::UDSEntry entry = fileToUDSEntry(file, url.adjusted(QUrl::StripTrailingSlash).path()); | ||
476 | listEntry(entry); | 482 | listEntry(entry); | ||
477 | 483 | | |||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 501 | { | |||
522 | FilePtr file(new File()); | 528 | FilePtr file(new File()); | ||
523 | file->setTitle(gdriveUrl.filename()); | 529 | file->setTitle(gdriveUrl.filename()); | ||
524 | file->setMimeType(File::folderMimeType()); | 530 | file->setMimeType(File::folderMimeType()); | ||
525 | 531 | | |||
526 | ParentReferencePtr parent(new ParentReference(parentId)); | 532 | ParentReferencePtr parent(new ParentReference(parentId)); | ||
527 | file->setParents(ParentReferencesList() << parent); | 533 | file->setParents(ParentReferencesList() << parent); | ||
528 | 534 | | |||
529 | FileCreateJob createJob(file, getAccount(accountId)); | 535 | FileCreateJob createJob(file, getAccount(accountId)); | ||
530 | runJob(createJob, url, accountId); | 536 | if (runJob(createJob, url, accountId)) { | ||
531 | | ||||
532 | finished(); | 537 | finished(); | ||
533 | } | 538 | } | ||
539 | } | ||||
534 | 540 | | |||
535 | void KIOGDrive::stat(const QUrl &url) | 541 | void KIOGDrive::stat(const QUrl &url) | ||
536 | { | 542 | { | ||
537 | qCDebug(GDRIVE) << "Going to stat()" << url; | 543 | qCDebug(GDRIVE) << "Going to stat()" << url; | ||
538 | 544 | | |||
539 | const auto gdriveUrl = GDriveUrl(url); | 545 | const auto gdriveUrl = GDriveUrl(url); | ||
540 | const QString accountId = gdriveUrl.account(); | 546 | const QString accountId = gdriveUrl.account(); | ||
541 | if (gdriveUrl.isRoot()) { | 547 | if (gdriveUrl.isRoot()) { | ||
Show All 15 Lines | 561 | = urlQuery.hasQueryItem(QStringLiteral("id")) | |||
557 | : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path(), | 563 | : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path(), | ||
558 | KIOGDrive::None); | 564 | KIOGDrive::None); | ||
559 | if (fileId.isEmpty()) { | 565 | if (fileId.isEmpty()) { | ||
560 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | 566 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | ||
561 | return; | 567 | return; | ||
562 | } | 568 | } | ||
563 | 569 | | |||
564 | FileFetchJob fileFetchJob(fileId, getAccount(accountId)); | 570 | FileFetchJob fileFetchJob(fileId, getAccount(accountId)); | ||
565 | runJob(fileFetchJob, url, accountId); | 571 | if (!runJob(fileFetchJob, url, accountId)) { | ||
572 | // runJob called error() | ||||
573 | return; | ||||
574 | } | ||||
566 | 575 | | |||
567 | const ObjectsList objects = fileFetchJob.items(); | 576 | const ObjectsList objects = fileFetchJob.items(); | ||
568 | if (objects.count() != 1) { | 577 | if (objects.count() != 1) { | ||
569 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | 578 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | ||
570 | return; | 579 | return; | ||
571 | } | 580 | } | ||
572 | 581 | | |||
573 | const FilePtr file = objects.first().dynamicCast<File>(); | 582 | const FilePtr file = objects.first().dynamicCast<File>(); | ||
Show All 33 Lines | 615 | : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path(), | |||
607 | KIOGDrive::PathIsFile); | 616 | KIOGDrive::PathIsFile); | ||
608 | if (fileId.isEmpty()) { | 617 | if (fileId.isEmpty()) { | ||
609 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | 618 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | ||
610 | return; | 619 | return; | ||
611 | } | 620 | } | ||
612 | 621 | | |||
613 | FileFetchJob fileFetchJob(fileId, getAccount(accountId)); | 622 | FileFetchJob fileFetchJob(fileId, getAccount(accountId)); | ||
614 | fileFetchJob.setFields({File::Fields::Id, File::Fields::MimeType, File::Fields::ExportLinks, File::Fields::DownloadUrl}); | 623 | fileFetchJob.setFields({File::Fields::Id, File::Fields::MimeType, File::Fields::ExportLinks, File::Fields::DownloadUrl}); | ||
615 | runJob(fileFetchJob, url, accountId); | 624 | if (!runJob(fileFetchJob, url, accountId)) { | ||
625 | // runJob called error() | ||||
626 | return; | ||||
627 | } | ||||
616 | 628 | | |||
617 | const ObjectsList objects = fileFetchJob.items(); | 629 | const ObjectsList objects = fileFetchJob.items(); | ||
618 | if (objects.count() != 1) { | 630 | if (objects.count() != 1) { | ||
619 | error(KIO::ERR_DOES_NOT_EXIST, url.fileName()); | 631 | error(KIO::ERR_DOES_NOT_EXIST, url.fileName()); | ||
620 | return; | 632 | return; | ||
621 | } | 633 | } | ||
622 | 634 | | |||
623 | FilePtr file = objects.first().dynamicCast<File>(); | 635 | FilePtr file = objects.first().dynamicCast<File>(); | ||
624 | QUrl downloadUrl; | 636 | QUrl downloadUrl; | ||
625 | if (GDriveHelper::isGDocsDocument(file)) { | 637 | if (GDriveHelper::isGDocsDocument(file)) { | ||
626 | downloadUrl = GDriveHelper::convertFromGDocs(file); | 638 | downloadUrl = GDriveHelper::convertFromGDocs(file); | ||
627 | } else { | 639 | } else { | ||
628 | downloadUrl = file->downloadUrl(); | 640 | downloadUrl = file->downloadUrl(); | ||
629 | } | 641 | } | ||
630 | 642 | | |||
631 | mimeType(file->mimeType()); | 643 | mimeType(file->mimeType()); | ||
632 | 644 | | |||
633 | FileFetchContentJob contentJob(downloadUrl, getAccount(accountId)); | 645 | FileFetchContentJob contentJob(downloadUrl, getAccount(accountId)); | ||
634 | runJob(contentJob, url, accountId); | 646 | if (!runJob(contentJob, url, accountId)) { | ||
647 | // runJob called error() | ||||
648 | return; | ||||
649 | } | ||||
635 | 650 | | |||
636 | QByteArray contentData = contentJob.data(); | 651 | QByteArray contentData = contentJob.data(); | ||
637 | 652 | | |||
638 | totalSize(contentData.size()); | 653 | totalSize(contentData.size()); | ||
639 | 654 | | |||
640 | // data() has a maximum transfer size of 14 MiB so we need to send it in chunks. | 655 | // data() has a maximum transfer size of 14 MiB so we need to send it in chunks. | ||
641 | // See TransferJob::slotDataReq. | 656 | // See TransferJob::slotDataReq. | ||
642 | int transferred = 0; | 657 | int transferred = 0; | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 876 | = urlQuery.hasQueryItem(QStringLiteral("id")) | |||
862 | ? urlQuery.queryItemValue(QStringLiteral("id")) | 877 | ? urlQuery.queryItemValue(QStringLiteral("id")) | ||
863 | : resolveFileIdFromPath(src.adjusted(QUrl::StripTrailingSlash).path()); | 878 | : resolveFileIdFromPath(src.adjusted(QUrl::StripTrailingSlash).path()); | ||
864 | if (sourceFileId.isEmpty()) { | 879 | if (sourceFileId.isEmpty()) { | ||
865 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | 880 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | ||
866 | return; | 881 | return; | ||
867 | } | 882 | } | ||
868 | FileFetchJob sourceFileFetchJob(sourceFileId, getAccount(sourceAccountId)); | 883 | FileFetchJob sourceFileFetchJob(sourceFileId, getAccount(sourceAccountId)); | ||
869 | sourceFileFetchJob.setFields({File::Fields::Id, File::Fields::ModifiedDate, File::Fields::LastViewedByMeDate, File::Fields::Description}); | 884 | sourceFileFetchJob.setFields({File::Fields::Id, File::Fields::ModifiedDate, File::Fields::LastViewedByMeDate, File::Fields::Description}); | ||
870 | runJob(sourceFileFetchJob, src, sourceAccountId); | 885 | if (!runJob(sourceFileFetchJob, src, sourceAccountId)) { | ||
886 | // runJob called error() | ||||
887 | return; | ||||
888 | } | ||||
871 | 889 | | |||
872 | const ObjectsList objects = sourceFileFetchJob.items(); | 890 | const ObjectsList objects = sourceFileFetchJob.items(); | ||
873 | if (objects.count() != 1) { | 891 | if (objects.count() != 1) { | ||
874 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | 892 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | ||
875 | return; | 893 | return; | ||
876 | } | 894 | } | ||
877 | 895 | | |||
878 | const FilePtr sourceFile = objects[0].dynamicCast<File>(); | 896 | const FilePtr sourceFile = objects[0].dynamicCast<File>(); | ||
Show All 15 Lines | |||||
894 | FilePtr destFile(new File); | 912 | FilePtr destFile(new File); | ||
895 | destFile->setTitle(destGDriveUrl.filename()); | 913 | destFile->setTitle(destGDriveUrl.filename()); | ||
896 | destFile->setModifiedDate(sourceFile->modifiedDate()); | 914 | destFile->setModifiedDate(sourceFile->modifiedDate()); | ||
897 | destFile->setLastViewedByMeDate(sourceFile->lastViewedByMeDate()); | 915 | destFile->setLastViewedByMeDate(sourceFile->lastViewedByMeDate()); | ||
898 | destFile->setDescription(sourceFile->description()); | 916 | destFile->setDescription(sourceFile->description()); | ||
899 | destFile->setParents(destParentReferences); | 917 | destFile->setParents(destParentReferences); | ||
900 | 918 | | |||
901 | FileCopyJob copyJob(sourceFile, destFile, getAccount(sourceAccountId)); | 919 | FileCopyJob copyJob(sourceFile, destFile, getAccount(sourceAccountId)); | ||
902 | runJob(copyJob, dest, sourceAccountId); | 920 | if (runJob(copyJob, dest, sourceAccountId)) { | ||
903 | | ||||
904 | finished(); | 921 | finished(); | ||
905 | } | 922 | } | ||
923 | } | ||||
906 | 924 | | |||
907 | void KIOGDrive::del(const QUrl &url, bool isfile) | 925 | void KIOGDrive::del(const QUrl &url, bool isfile) | ||
908 | { | 926 | { | ||
909 | // FIXME: Verify that a single file cannot actually have multiple parent | 927 | // FIXME: Verify that a single file cannot actually have multiple parent | ||
910 | // references. If it can, then we need to be more careful: currently this | 928 | // references. If it can, then we need to be more careful: currently this | ||
911 | // implementation will simply remove the file from all it's parents but | 929 | // implementation will simply remove the file from all it's parents but | ||
912 | // it actually should just remove the current parent reference | 930 | // it actually should just remove the current parent reference | ||
913 | 931 | | |||
Show All 31 Lines | 955 | if (gdriveUrl.isAccountRoot()) { | |||
945 | return; | 963 | return; | ||
946 | } | 964 | } | ||
947 | 965 | | |||
948 | // GDrive allows us to delete entire directory even when it's not empty, | 966 | // GDrive allows us to delete entire directory even when it's not empty, | ||
949 | // so we need to emulate the normal behavior ourselves by checking number of | 967 | // so we need to emulate the normal behavior ourselves by checking number of | ||
950 | // child references | 968 | // child references | ||
951 | if (!isfile) { | 969 | if (!isfile) { | ||
952 | ChildReferenceFetchJob referencesFetch(fileId, getAccount(accountId)); | 970 | ChildReferenceFetchJob referencesFetch(fileId, getAccount(accountId)); | ||
953 | runJob(referencesFetch, url, accountId); | 971 | if (!runJob(referencesFetch, url, accountId)) { | ||
972 | // runJob called error() | ||||
973 | return; | ||||
974 | } | ||||
954 | const bool isEmpty = !referencesFetch.items().count(); | 975 | const bool isEmpty = !referencesFetch.items().count(); | ||
955 | 976 | | |||
956 | if (!isEmpty && metaData(QStringLiteral("recurse")) != QLatin1String("true")) { | 977 | if (!isEmpty && metaData(QStringLiteral("recurse")) != QLatin1String("true")) { | ||
957 | error(KIO::ERR_CANNOT_RMDIR, url.path()); | 978 | error(KIO::ERR_CANNOT_RMDIR, url.path()); | ||
958 | return; | 979 | return; | ||
959 | } | 980 | } | ||
960 | } | 981 | } | ||
961 | 982 | | |||
962 | FileTrashJob trashJob(fileId, getAccount(accountId)); | 983 | FileTrashJob trashJob(fileId, getAccount(accountId)); | ||
963 | runJob(trashJob, url, accountId); | 984 | if (runJob(trashJob, url, accountId)) { | ||
964 | | ||||
965 | m_cache.removePath(url.path()); | 985 | m_cache.removePath(url.path()); | ||
966 | | ||||
967 | finished(); | 986 | finished(); | ||
968 | 987 | } | |||
969 | } | 988 | } | ||
970 | 989 | | |||
971 | void KIOGDrive::rename(const QUrl &src, const QUrl &dest, KIO::JobFlags flags) | 990 | void KIOGDrive::rename(const QUrl &src, const QUrl &dest, KIO::JobFlags flags) | ||
972 | { | 991 | { | ||
973 | Q_UNUSED(flags) | 992 | Q_UNUSED(flags) | ||
974 | qCDebug(GDRIVE) << "Renaming" << src << "to" << dest; | 993 | qCDebug(GDRIVE) << "Renaming" << src << "to" << dest; | ||
975 | 994 | | |||
976 | const auto srcGDriveUrl = GDriveUrl(src); | 995 | const auto srcGDriveUrl = GDriveUrl(src); | ||
Show All 24 Lines | 1019 | : resolveFileIdFromPath(src.adjusted(QUrl::StripTrailingSlash).path(), | |||
1001 | KIOGDrive::PathIsFile); | 1020 | KIOGDrive::PathIsFile); | ||
1002 | if (sourceFileId.isEmpty()) { | 1021 | if (sourceFileId.isEmpty()) { | ||
1003 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | 1022 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | ||
1004 | return; | 1023 | return; | ||
1005 | } | 1024 | } | ||
1006 | 1025 | | |||
1007 | // We need to fetch ALL, so that we can do update later | 1026 | // We need to fetch ALL, so that we can do update later | ||
1008 | FileFetchJob sourceFileFetchJob(sourceFileId, getAccount(sourceAccountId)); | 1027 | FileFetchJob sourceFileFetchJob(sourceFileId, getAccount(sourceAccountId)); | ||
1009 | runJob(sourceFileFetchJob, src, sourceAccountId); | 1028 | if (!runJob(sourceFileFetchJob, src, sourceAccountId)) { | ||
1029 | // runJob called error() | ||||
1030 | return; | ||||
1031 | } | ||||
1010 | 1032 | | |||
1011 | const ObjectsList objects = sourceFileFetchJob.items(); | 1033 | const ObjectsList objects = sourceFileFetchJob.items(); | ||
1012 | if (objects.count() != 1) { | 1034 | if (objects.count() != 1) { | ||
1013 | qCDebug(GDRIVE) << "FileFetchJob retrieved" << objects.count() << "items, while only one was expected."; | 1035 | qCDebug(GDRIVE) << "FileFetchJob retrieved" << objects.count() << "items, while only one was expected."; | ||
1014 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | 1036 | error(KIO::ERR_DOES_NOT_EXIST, src.path()); | ||
1015 | return; | 1037 | return; | ||
1016 | } | 1038 | } | ||
1017 | 1039 | | |||
Show All 35 Lines | |||||
1053 | } | 1075 | } | ||
1054 | 1076 | | |||
1055 | FilePtr destFile(sourceFile); | 1077 | FilePtr destFile(sourceFile); | ||
1056 | destFile->setTitle(destGDriveUrl.filename()); | 1078 | destFile->setTitle(destGDriveUrl.filename()); | ||
1057 | destFile->setParents(parentReferences); | 1079 | destFile->setParents(parentReferences); | ||
1058 | 1080 | | |||
1059 | FileModifyJob modifyJob(destFile, getAccount(sourceAccountId)); | 1081 | FileModifyJob modifyJob(destFile, getAccount(sourceAccountId)); | ||
1060 | modifyJob.setUpdateModifiedDate(true); | 1082 | modifyJob.setUpdateModifiedDate(true); | ||
1061 | runJob(modifyJob, dest, sourceAccountId); | 1083 | if (runJob(modifyJob, dest, sourceAccountId)) { | ||
1062 | | ||||
1063 | finished(); | 1084 | finished(); | ||
1064 | } | 1085 | } | ||
1086 | } | ||||
1065 | 1087 | | |||
1066 | void KIOGDrive::mimetype(const QUrl &url) | 1088 | void KIOGDrive::mimetype(const QUrl &url) | ||
1067 | { | 1089 | { | ||
1068 | qCDebug(GDRIVE) << Q_FUNC_INFO << url; | 1090 | qCDebug(GDRIVE) << Q_FUNC_INFO << url; | ||
1069 | 1091 | | |||
1070 | const QUrlQuery urlQuery(url); | 1092 | const QUrlQuery urlQuery(url); | ||
1071 | const QString fileId | 1093 | const QString fileId | ||
1072 | = urlQuery.hasQueryItem(QStringLiteral("id")) | 1094 | = urlQuery.hasQueryItem(QStringLiteral("id")) | ||
1073 | ? urlQuery.queryItemValue(QStringLiteral("id")) | 1095 | ? urlQuery.queryItemValue(QStringLiteral("id")) | ||
1074 | : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path()); | 1096 | : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path()); | ||
1075 | if (fileId.isEmpty()) { | 1097 | if (fileId.isEmpty()) { | ||
1076 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | 1098 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | ||
1077 | return; | 1099 | return; | ||
1078 | } | 1100 | } | ||
1079 | const QString accountId = GDriveUrl(url).account(); | 1101 | const QString accountId = GDriveUrl(url).account(); | ||
1080 | 1102 | | |||
1081 | FileFetchJob fileFetchJob(fileId, getAccount(accountId)); | 1103 | FileFetchJob fileFetchJob(fileId, getAccount(accountId)); | ||
1082 | fileFetchJob.setFields({File::Fields::Id, File::Fields::MimeType}); | 1104 | fileFetchJob.setFields({File::Fields::Id, File::Fields::MimeType}); | ||
1083 | runJob(fileFetchJob, url, accountId); | 1105 | if (!runJob(fileFetchJob, url, accountId)) { | ||
1106 | // runJob called error() | ||||
1107 | return; | ||||
1108 | } | ||||
1084 | 1109 | | |||
1085 | const ObjectsList objects = fileFetchJob.items(); | 1110 | const ObjectsList objects = fileFetchJob.items(); | ||
1086 | if (objects.count() != 1) { | 1111 | if (objects.count() != 1) { | ||
1087 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | 1112 | error(KIO::ERR_DOES_NOT_EXIST, url.path()); | ||
1088 | return; | 1113 | return; | ||
1089 | } | 1114 | } | ||
1090 | 1115 | | |||
1091 | const FilePtr file = objects.first().dynamicCast<File>(); | 1116 | const FilePtr file = objects.first().dynamicCast<File>(); | ||
1092 | mimeType(file->mimeType()); | 1117 | mimeType(file->mimeType()); | ||
1093 | finished(); | 1118 | finished(); | ||
1094 | } | 1119 | } | ||
1095 | 1120 | | |||
1096 | #include "kio_gdrive.moc" | 1121 | #include "kio_gdrive.moc" |
This message is a bit cryptic. How about "fileSystemFreeSpace is not supported for gdrive root urls?"