@Override
    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException {
        // Must split otherwise 413 Request Entity Too Large is returned
        for(List<Path> partition : new Partition<>(new ArrayList<>(files.keySet()),
                new HostPreferences(session.getHost()).getInteger("googledrive.delete.multiple.partition"))) {
            final BatchRequest batch = session.getClient().batch();
            final List<BackgroundException> failures = new CopyOnWriteArrayList<>();
            for(Path f : partition) {
                try {
                    if(new SimplePathPredicate(DriveHomeFinderService.SHARED_DRIVES_NAME).test(f.getParent())) {
                        session.getClient().teamdrives().delete(fileid.getFileId(f))
                                .queue(batch, new DeleteBatchCallback<>(f, failures, callback));
                    }
                    else {
                        if(f.attributes().isHidden()) {
                            log.warn(String.format("Delete file %s already in trash", f));
                            new DriveBatchDeleteFeature(session, fileid).queue(f, batch, callback, failures);
                            continue;
                        }
                        final File properties = new File();
                        properties.setTrashed(true);
                        session.getClient().files().update(fileid.getFileId(f), properties)
                                .setSupportsAllDrives(new HostPreferences(session.getHost()).getBoolean("googledrive.teamdrive.enable"))
                                .queue(batch, new DeleteBatchCallback<>(f, failures, callback));
                    }
                }
                catch(IOException e) {
                    throw new DriveExceptionMappingService(fileid).map("Cannot delete {0}", e, f);
                }
            }
            if(!partition.isEmpty()) {
                try {
                    batch.execute();
                }
                catch(IOException e) {
                    throw new DriveExceptionMappingService(fileid).map(e);
                }
                for(BackgroundException e : failures) {
                    throw e;
                }
            }
        }
    }
@Test
    public void testDeleteFromTrash() throws Exception {
        final DriveFileIdProvider fileid = new DriveFileIdProvider(session);
        final Path file = new DriveTouchFeature(session, fileid).touch(
                new Path(DriveHomeFinderService.MYDRIVE_FOLDER, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
        final String fileId = file.attributes().getFileId();
        new DriveBatchTrashFeature(session, fileid).delete(Collections.singletonList(file), new DisabledPasswordCallback(), new Delete.DisabledCallback());
        assertFalse(new DriveFindFeature(session, fileid).find(file));
        assertTrue(new DriveFindFeature(session, fileid).find(file.withAttributes(new PathAttributes().withFileId(fileId))));
        final PathAttributes attributesInTrash = new DriveAttributesFinderFeature(session, fileid).find(file.withAttributes(new PathAttributes().withFileId(fileId)));
        assertTrue(attributesInTrash.isHidden());
        new DriveBatchTrashFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(attributesInTrash)), new DisabledPasswordCallback(), new Delete.DisabledCallback());
        assertFalse(new DriveFindFeature(session, fileid).find(file.withAttributes(attributesInTrash)));
    }