Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public PathAttributes find(final Path file, final ListProgressListener listener)
if(new SimplePathPredicate(DriveHomeFinderService.SHARED_DRIVES_NAME).test(file.getParent())) {
list = new DriveTeamDrivesListService(session, fileid).list(file.getParent(), listener);
}
else if(new SimplePathPredicate(DriveHomeFinderService.TRASH_FOLDER).test(file.getParent())) {
list = new DriveTrashedListService(session, fileid).list(file.getParent(), listener);
}
else {
list = new FileidDriveListService(session, fileid, query).list(file.getParent(), listener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public class DriveHomeFinderService extends AbstractHomeFeature {
= 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_FOLDER
= 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 {
return MYDRIVE_FOLDER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public AttributedList<Path> 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_FOLDER);
listener.chunk(directory, list);
return list;
}
Expand All @@ -49,6 +50,9 @@ public AttributedList<Path> 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_FOLDER).test(directory)) {
return new DriveTrashedListService(session, fileid).list(directory, listener);
}
return new DriveDefaultListService(session, fileid).list(directory, listener);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ch.cyberduck.core.googledrive;

/*
* Copyright (c) 2002-2023 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;
import ch.cyberduck.core.exception.BackgroundException;

public class DriveTrashedListService extends AbstractDriveListService {

public DriveTrashedListService(final DriveSession session, final DriveFileIdProvider fileid) {
super(session, fileid);
}

@Override
protected String query(final Path directory, final ListProgressListener listener) throws BackgroundException {
return "trashed = true";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package ch.cyberduck.core.googledrive;

/*
* Copyright (c) 2002-2023 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.AlphanumericRandomStringService;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.DisabledListProgressListener;
import ch.cyberduck.core.DisabledLoginCallback;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.features.Delete;
import ch.cyberduck.core.transfer.TransferStatus;
import ch.cyberduck.test.IntegrationTest;

import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.util.Collections;
import java.util.EnumSet;

import static org.junit.Assert.*;

@Category(IntegrationTest.class)
public class DriveTrashedListServiceTest extends AbstractDriveTest {

@Test
public void testList() throws Exception {
final DriveFileIdProvider fileid = new DriveFileIdProvider(session);
final Path home = DriveHomeFinderService.MYDRIVE_FOLDER;
final Path test = new DriveTouchFeature(session, fileid).touch(new Path(home,
new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
new DriveTrashFeature(session, fileid).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
final AttributedList<Path> list = new DriveTrashedListService(session, fileid).list(DriveHomeFinderService.TRASH_FOLDER, new DisabledListProgressListener());
assertFalse(list.isEmpty());
for(Path f : list) {
assertTrue(f.attributes().isHidden());
assertEquals(f.attributes(), new DriveAttributesFinderFeature(session, fileid).find(f));
}
new DriveDeleteFeature(session, fileid).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
}