@Test public void testCopyFileZeroLength() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)); test.attributes().setSize(0L); new GoogleStorageTouchFeature(session).touch(test, new TransferStatus().withMime("application/cyberduck").withMetadata(Collections.singletonMap("cyberduck", "set"))); final Path copy = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)); new GoogleStorageCopyFeature(session).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback()); assertTrue(new GoogleStorageFindFeature(session).find(test)); new GoogleStorageDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertTrue(new GoogleStorageFindFeature(session).find(copy)); assertEquals("set", new GoogleStorageMetadataFeature(session).getMetadata(copy).get("cyberduck")); new GoogleStorageDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final StorageObject object = session.getClient().objects().copy(containerService.getContainer(source).getName(), containerService.getKey(source), containerService.getContainer(target).getName(), containerService.getKey(target), session.getClient().objects().get( containerService.getContainer(source).getName(), containerService.getKey(source)).execute()).execute(); return new Path(target.getParent(), target.getName(), target.getType(), new GoogleStorageAttributesFinderFeature(session).toAttributes(object)); } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Cannot copy {0}", e, source); } }
GoogleStorageCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final StorageObject object = session.getClient().objects().copy(containerService.getContainer(source).getName(), containerService.getKey(source), containerService.getContainer(target).getName(), containerService.getKey(target), session.getClient().objects().get( containerService.getContainer(source).getName(), containerService.getKey(source)).execute()).execute(); return new Path(target.getParent(), target.getName(), target.getType(), new GoogleStorageAttributesFinderFeature(session).toAttributes(object)); } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Cannot copy {0}", e, source); } } }
GoogleStorageCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final StorageObject object = session.getClient().objects().copy(containerService.getContainer(source).getName(), containerService.getKey(source), containerService.getContainer(target).getName(), containerService.getKey(target), session.getClient().objects().get( containerService.getContainer(source).getName(), containerService.getKey(source)).execute()).execute(); return new Path(target.getParent(), target.getName(), target.getType(), new GoogleStorageAttributesFinderFeature(session).toAttributes(object)); } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Cannot copy {0}", e, source); } } GoogleStorageCopyFeature(final GoogleStorageSession session); }
GoogleStorageCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final StorageObject object = session.getClient().objects().copy(containerService.getContainer(source).getName(), containerService.getKey(source), containerService.getContainer(target).getName(), containerService.getKey(target), session.getClient().objects().get( containerService.getContainer(source).getName(), containerService.getKey(source)).execute()).execute(); return new Path(target.getParent(), target.getName(), target.getType(), new GoogleStorageAttributesFinderFeature(session).toAttributes(object)); } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Cannot copy {0}", e, source); } } GoogleStorageCopyFeature(final GoogleStorageSession session); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target); }
GoogleStorageCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final StorageObject object = session.getClient().objects().copy(containerService.getContainer(source).getName(), containerService.getKey(source), containerService.getContainer(target).getName(), containerService.getKey(target), session.getClient().objects().get( containerService.getContainer(source).getName(), containerService.getKey(source)).execute()).execute(); return new Path(target.getParent(), target.getName(), target.getType(), new GoogleStorageAttributesFinderFeature(session).toAttributes(object)); } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Cannot copy {0}", e, source); } } GoogleStorageCopyFeature(final GoogleStorageSession session); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target);  }