From 4b8acf6d7447272ee42a78e77bafdb6c99c168b6 Mon Sep 17 00:00:00 2001 From: Jonathan Roberts Date: Thu, 13 Oct 2022 14:29:10 +0100 Subject: [PATCH] Add support for reading from Shared with me --- src/tentaclio_gdrive/clients/google_drive_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tentaclio_gdrive/clients/google_drive_client.py b/src/tentaclio_gdrive/clients/google_drive_client.py index c15b785..9c02200 100644 --- a/src/tentaclio_gdrive/clients/google_drive_client.py +++ b/src/tentaclio_gdrive/clients/google_drive_client.py @@ -164,7 +164,7 @@ def _drive(self): drives = self._get_drives() if self.drive_name not in drives: names = [d for d in drives] - raise ValueError(f"Drive name (hostname) should be one of {names}") + raise ValueError(f"Drive name {self.drive_name} should be one of {names}") return drives[self.drive_name] def _connect(self) -> "GoogleDriveFSClient": @@ -262,12 +262,15 @@ def _get_path_descriptors(self, ignore_tail=False) -> List[_GoogleFileDescriptor parts = self.path_parts if ignore_tail: parts = parts[:-1] + if self.drive_name == "Shared with me": + return [self._get_file_descriptor_by_name(parts[0])] return list(self._path_parts_to_descriptors(self._drive, parts)) def _path_parts_to_descriptors( self, drive: _GoogleDriveDescriptor, path_parts: Iterable[str] ) -> List[_GoogleFileDescriptor]: """Convert the path parts into google drive descriptors.""" + file_descriptors = [drive.root_descriptor] parent = None for pathPart in path_parts: