diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveFileIdProvider.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveFileIdProvider.java index 1c7a5d6a79c..37e2109a663 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveFileIdProvider.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveFileIdProvider.java @@ -49,7 +49,8 @@ public String getFileId(final Path file) throws BackgroundException { if(file.isRoot() || new SimplePathPredicate(file).test(DriveHomeFinderService.MYDRIVE_FOLDER) || new SimplePathPredicate(file).test(DriveHomeFinderService.SHARED_FOLDER_NAME) - || new SimplePathPredicate(file).test(DriveHomeFinderService.SHARED_DRIVES_NAME)) { + || new SimplePathPredicate(file).test(DriveHomeFinderService.SHARED_DRIVES_NAME) + || new SimplePathPredicate(file).test(DriveHomeFinderService.TRASH_NAME)) { return DriveHomeFinderService.ROOT_FOLDER_ID; } final String cached = super.getFileId(file); diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveHomeFinderService.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveHomeFinderService.java index f02cd90b688..3e8894e3127 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveHomeFinderService.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveHomeFinderService.java @@ -29,16 +29,20 @@ public class DriveHomeFinderService extends AbstractHomeFeature { public static final String ROOT_FOLDER_ID = "root"; public static final Path MYDRIVE_FOLDER - = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("My Drive", "Google Drive")), - EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume), new PathAttributes().withFileId(ROOT_FOLDER_ID)); + = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("My Drive", "Google Drive")), + EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume), new PathAttributes().withFileId(ROOT_FOLDER_ID)); public static final Path SHARED_FOLDER_NAME - = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("Shared with me", "Google Drive")), - EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume)); + = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("Shared with me", "Google Drive")), + EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume)); public static final Path SHARED_DRIVES_NAME - = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("Shared Drives", "Google Drive")), - EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume)); + = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("Shared Drives", "Google Drive")), + EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume)); + + public static final Path TRASH_NAME + = new Path(PathNormalizer.normalize(LocaleFactory.localizedString("Trash", "Google Drive")), + EnumSet.of(Path.Type.directory, Path.Type.placeholder, Path.Type.volume)); @Override public Path find() throws BackgroundException { diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveListService.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveListService.java index 739b03950bc..9fad749c090 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveListService.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveListService.java @@ -39,6 +39,7 @@ public AttributedList list(final Path directory, final ListProgressListene list.add(DriveHomeFinderService.MYDRIVE_FOLDER); list.add(DriveHomeFinderService.SHARED_FOLDER_NAME); list.add(DriveHomeFinderService.SHARED_DRIVES_NAME); + list.add(DriveHomeFinderService.TRASH_NAME); listener.chunk(directory, list); return list; } @@ -49,6 +50,9 @@ public AttributedList list(final Path directory, final ListProgressListene if(new SimplePathPredicate(DriveHomeFinderService.SHARED_DRIVES_NAME).test(directory)) { return new DriveTeamDrivesListService(session, fileid).list(directory, listener); } + if(new SimplePathPredicate(DriveHomeFinderService.TRASH_NAME).test(directory)) { + return new DriveTrashListService(session, fileid).list(directory, listener); + } return new DriveDefaultListService(session, fileid).list(directory, listener); } } diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveTrashListService.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveTrashListService.java new file mode 100644 index 00000000000..ab16151457a --- /dev/null +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveTrashListService.java @@ -0,0 +1,35 @@ +package ch.cyberduck.core.googledrive; + +/* + * Copyright (c) 2002-2024 iterate GmbH. All rights reserved. + * https://cyberduck.io/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +import ch.cyberduck.core.ListProgressListener; +import ch.cyberduck.core.Path; + +public class DriveTrashListService extends AbstractDriveListService { + + public DriveTrashListService(final DriveSession session, final DriveFileIdProvider fileid) { + super(session, fileid); + } + + public DriveTrashListService(final DriveSession session, final DriveFileIdProvider fileid, final int pagesize) { + super(session, fileid, pagesize); + } + + @Override + protected String query(final Path directory, final ListProgressListener listener) { + return "trashed = true"; + } +}