@Test public void testFindKeyWithSpace() throws Exception { final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, "t f", EnumSet.of(Path.Type.file)); final List<MultipartUpload> list = new S3DefaultMultipartService(session).find(test); assertTrue(list.isEmpty()); }
@Override public List<MultipartUpload> find(final Path file) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Finding multipart uploads for %s", file)); } final List<MultipartUpload> uploads = new ArrayList<>(); String nextUploadIdMarker = null; String nextKeyMarker = null; boolean isTruncated; do { final String prefix = containerService.isContainer(file) ? StringUtils.EMPTY : containerService.getKey(file); final MultipartUploadChunk chunk; try { chunk = session.getClient().multipartListUploadsChunked( containerService.getContainer(file).getName(), prefix, String.valueOf(Path.DELIMITER), nextKeyMarker, nextUploadIdMarker, null, false); } catch(S3ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Upload {0} failed", e, file); if(failure instanceof NotfoundException) { return Collections.emptyList(); } if(failure instanceof InteroperabilityException) { return Collections.emptyList(); } throw failure; } uploads.addAll(Arrays.asList(chunk.getUploads())); if(log.isInfoEnabled()) { log.info(String.format("Found %d previous multipart uploads for %s", uploads.size(), file)); } uploads.sort(new Comparator<MultipartUpload>() { @Override public int compare(final MultipartUpload o1, final MultipartUpload o2) { return -o1.getInitiatedDate().compareTo(o2.getInitiatedDate()); } }); nextKeyMarker = chunk.getPriorLastKey(); nextUploadIdMarker = chunk.getPriorLastIdMarker(); isTruncated = !chunk.isListingComplete(); } while(isTruncated && nextUploadIdMarker != null); if(log.isInfoEnabled()) { for(MultipartUpload upload : uploads) { log.info(String.format("Found multipart upload %s for %s", upload, file)); } } return uploads; }
S3DefaultMultipartService implements S3MultipartService { @Override public List<MultipartUpload> find(final Path file) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Finding multipart uploads for %s", file)); } final List<MultipartUpload> uploads = new ArrayList<>(); String nextUploadIdMarker = null; String nextKeyMarker = null; boolean isTruncated; do { final String prefix = containerService.isContainer(file) ? StringUtils.EMPTY : containerService.getKey(file); final MultipartUploadChunk chunk; try { chunk = session.getClient().multipartListUploadsChunked( containerService.getContainer(file).getName(), prefix, String.valueOf(Path.DELIMITER), nextKeyMarker, nextUploadIdMarker, null, false); } catch(S3ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Upload {0} failed", e, file); if(failure instanceof NotfoundException) { return Collections.emptyList(); } if(failure instanceof InteroperabilityException) { return Collections.emptyList(); } throw failure; } uploads.addAll(Arrays.asList(chunk.getUploads())); if(log.isInfoEnabled()) { log.info(String.format("Found %d previous multipart uploads for %s", uploads.size(), file)); } uploads.sort(new Comparator<MultipartUpload>() { @Override public int compare(final MultipartUpload o1, final MultipartUpload o2) { return -o1.getInitiatedDate().compareTo(o2.getInitiatedDate()); } }); nextKeyMarker = chunk.getPriorLastKey(); nextUploadIdMarker = chunk.getPriorLastIdMarker(); isTruncated = !chunk.isListingComplete(); } while(isTruncated && nextUploadIdMarker != null); if(log.isInfoEnabled()) { for(MultipartUpload upload : uploads) { log.info(String.format("Found multipart upload %s for %s", upload, file)); } } return uploads; } }
S3DefaultMultipartService implements S3MultipartService { @Override public List<MultipartUpload> find(final Path file) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Finding multipart uploads for %s", file)); } final List<MultipartUpload> uploads = new ArrayList<>(); String nextUploadIdMarker = null; String nextKeyMarker = null; boolean isTruncated; do { final String prefix = containerService.isContainer(file) ? StringUtils.EMPTY : containerService.getKey(file); final MultipartUploadChunk chunk; try { chunk = session.getClient().multipartListUploadsChunked( containerService.getContainer(file).getName(), prefix, String.valueOf(Path.DELIMITER), nextKeyMarker, nextUploadIdMarker, null, false); } catch(S3ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Upload {0} failed", e, file); if(failure instanceof NotfoundException) { return Collections.emptyList(); } if(failure instanceof InteroperabilityException) { return Collections.emptyList(); } throw failure; } uploads.addAll(Arrays.asList(chunk.getUploads())); if(log.isInfoEnabled()) { log.info(String.format("Found %d previous multipart uploads for %s", uploads.size(), file)); } uploads.sort(new Comparator<MultipartUpload>() { @Override public int compare(final MultipartUpload o1, final MultipartUpload o2) { return -o1.getInitiatedDate().compareTo(o2.getInitiatedDate()); } }); nextKeyMarker = chunk.getPriorLastKey(); nextUploadIdMarker = chunk.getPriorLastIdMarker(); isTruncated = !chunk.isListingComplete(); } while(isTruncated && nextUploadIdMarker != null); if(log.isInfoEnabled()) { for(MultipartUpload upload : uploads) { log.info(String.format("Found multipart upload %s for %s", upload, file)); } } return uploads; } S3DefaultMultipartService(final S3Session session); }
S3DefaultMultipartService implements S3MultipartService { @Override public List<MultipartUpload> find(final Path file) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Finding multipart uploads for %s", file)); } final List<MultipartUpload> uploads = new ArrayList<>(); String nextUploadIdMarker = null; String nextKeyMarker = null; boolean isTruncated; do { final String prefix = containerService.isContainer(file) ? StringUtils.EMPTY : containerService.getKey(file); final MultipartUploadChunk chunk; try { chunk = session.getClient().multipartListUploadsChunked( containerService.getContainer(file).getName(), prefix, String.valueOf(Path.DELIMITER), nextKeyMarker, nextUploadIdMarker, null, false); } catch(S3ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Upload {0} failed", e, file); if(failure instanceof NotfoundException) { return Collections.emptyList(); } if(failure instanceof InteroperabilityException) { return Collections.emptyList(); } throw failure; } uploads.addAll(Arrays.asList(chunk.getUploads())); if(log.isInfoEnabled()) { log.info(String.format("Found %d previous multipart uploads for %s", uploads.size(), file)); } uploads.sort(new Comparator<MultipartUpload>() { @Override public int compare(final MultipartUpload o1, final MultipartUpload o2) { return -o1.getInitiatedDate().compareTo(o2.getInitiatedDate()); } }); nextKeyMarker = chunk.getPriorLastKey(); nextUploadIdMarker = chunk.getPriorLastIdMarker(); isTruncated = !chunk.isListingComplete(); } while(isTruncated && nextUploadIdMarker != null); if(log.isInfoEnabled()) { for(MultipartUpload upload : uploads) { log.info(String.format("Found multipart upload %s for %s", upload, file)); } } return uploads; } S3DefaultMultipartService(final S3Session session); @Override List<MultipartUpload> find(final Path file); @Override List<MultipartPart> list(final MultipartUpload upload); @Override void delete(final MultipartUpload upload); }
S3DefaultMultipartService implements S3MultipartService { @Override public List<MultipartUpload> find(final Path file) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Finding multipart uploads for %s", file)); } final List<MultipartUpload> uploads = new ArrayList<>(); String nextUploadIdMarker = null; String nextKeyMarker = null; boolean isTruncated; do { final String prefix = containerService.isContainer(file) ? StringUtils.EMPTY : containerService.getKey(file); final MultipartUploadChunk chunk; try { chunk = session.getClient().multipartListUploadsChunked( containerService.getContainer(file).getName(), prefix, String.valueOf(Path.DELIMITER), nextKeyMarker, nextUploadIdMarker, null, false); } catch(S3ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Upload {0} failed", e, file); if(failure instanceof NotfoundException) { return Collections.emptyList(); } if(failure instanceof InteroperabilityException) { return Collections.emptyList(); } throw failure; } uploads.addAll(Arrays.asList(chunk.getUploads())); if(log.isInfoEnabled()) { log.info(String.format("Found %d previous multipart uploads for %s", uploads.size(), file)); } uploads.sort(new Comparator<MultipartUpload>() { @Override public int compare(final MultipartUpload o1, final MultipartUpload o2) { return -o1.getInitiatedDate().compareTo(o2.getInitiatedDate()); } }); nextKeyMarker = chunk.getPriorLastKey(); nextUploadIdMarker = chunk.getPriorLastIdMarker(); isTruncated = !chunk.isListingComplete(); } while(isTruncated && nextUploadIdMarker != null); if(log.isInfoEnabled()) { for(MultipartUpload upload : uploads) { log.info(String.format("Found multipart upload %s for %s", upload, file)); } } return uploads; } S3DefaultMultipartService(final S3Session session); @Override List<MultipartUpload> find(final Path file); @Override List<MultipartPart> list(final MultipartUpload upload); @Override void delete(final MultipartUpload upload); static final int MAXIMUM_UPLOAD_PARTS; }