@Override
    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException {
        for(Path file : files.keySet()) {
            if(containerService.isContainer(file)) {
                continue;
            }
            callback.delete(file);
            if(file.getType().contains(Path.Type.upload)) {
                new B2LargeUploadPartService(session, fileid).delete(file.attributes().getVersionId());
            }
            else {
                if(file.isDirectory()) {
                    // Delete /.bzEmpty if any
                    final String placeholder;
                    try {
                        placeholder = fileid.getVersionId(file);
                    }
                    catch(NotfoundException e) {
                        log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file));
                        continue;
                    }
                    if(null == placeholder) {
                        continue;
                    }
                    try {
                        session.getClient().deleteFileVersion(containerService.getKey(file), placeholder);
                    }
                    catch(B2ApiException e) {
                        log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file));
                    }
                    catch(IOException e) {
                        throw new DefaultIOExceptionMappingService().map("Cannot delete {0}", e, file);
                    }
                }
                else if(file.isFile()) {
                    try {
                        if(!versioning.isEnabled() || null == file.attributes().getVersionId()) {
                            // Add hide marker
                            if(log.isDebugEnabled()) {
                                log.debug(String.format("Add hide marker %s of %s", file.attributes().getVersionId(), file));
                            }
                            try {
                                session.getClient().hideFile(fileid.getVersionId(containerService.getContainer(file)), containerService.getKey(file));
                            }
                            catch(B2ApiException e) {
                                if("already_hidden".equalsIgnoreCase(e.getCode())) {
                                    log.warn(String.format("Ignore failure %s hiding file %s already hidden", e.getMessage(), file));
                                }
                                else {
                                    throw e;
                                }
                            }
                        }
                        else {
                            // Delete specific version
                            if(log.isDebugEnabled()) {
                                log.debug(String.format("Delete version %s of %s", file.attributes().getVersionId(), file));
                            }
                            session.getClient().deleteFileVersion(containerService.getKey(file), file.attributes().getVersionId());
                        }
                    }
                    catch(B2ApiException e) {
                        throw new B2ExceptionMappingService(fileid).map("Cannot delete {0}", e, file);
                    }
                    catch(IOException e) {
                        throw new DefaultIOExceptionMappingService().map("Cannot delete {0}", e, file);
                    }
                }
                fileid.cache(file, null);
            }
        }
        for(Path file : files.keySet()) {
            try {
                if(containerService.isContainer(file)) {
                    callback.delete(file);
                    // Finally delete bucket itself
                    session.getClient().deleteBucket(fileid.getVersionId(file));
                }
            }
            catch(B2ApiException e) {
                throw new B2ExceptionMappingService(fileid).map("Cannot delete {0}", e, file);
            }
            catch(IOException e) {
                throw new DefaultIOExceptionMappingService().map("Cannot delete {0}", e, file);
            }
        }
    }
@Test
    public void testHide() throws Exception {
        final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
        final Path bucket = new B2DirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
        final Path file = new Path(bucket, String.format("%s %s", new AlphanumericRandomStringService().random(), "1"), EnumSet.of(Path.Type.file));
        new B2TouchFeature(session, fileid).touch(file, new TransferStatus());
        new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(PathAttributes.EMPTY)), new DisabledLoginCallback(), new Delete.DisabledCallback());
        assertFalse(new B2FindFeature(session, fileid).find(file));
        assertFalse(new DefaultFindFeature(session).find(file));
        new B2DeleteFeature(session, fileid).delete(new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener()).toList(), new DisabledLoginCallback(), new Delete.DisabledCallback());
        new B2DeleteFeature(session, new B2VersionIdProvider(session)).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }