@Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Children for %s", directory)); } final Set<TransferItem> children = new HashSet<TransferItem>(); final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache); if(finder.find(directory)) { children.addAll(download.list(session, directory, local, listener)); } if(local.exists()) { children.addAll(upload.list(session, directory, local, listener)); } return new ArrayList<TransferItem>(children); }
/** * Skip files that already exist on the server. */ @Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(parent.isExists()) { if(local.isFile()) { if(find.withCache(cache).find(file)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s", file)); } return false; } } } return super.accept(file, local, parent); } }
@Override public boolean find(final Path file) throws BackgroundException { final Vault vault = registry.find(session, file); if(vault.equals(Vault.DISABLED)) { if(autodetect) { final Path directory = file.getParent(); final Path key = new Path(directory, DefaultVaultRegistry.DEFAULT_MASTERKEY_FILE_NAME, EnumSet.of(Path.Type.file)); if(proxy.withCache(cache).find(key)) { if(log.isInfoEnabled()) { log.info(String.format("Found master key %s", key)); } try { if(log.isInfoEnabled()) { log.info(String.format("Found vault %s", directory)); } return lookup.load(directory, DefaultVaultRegistry.DEFAULT_MASTERKEY_FILE_NAME, DefaultVaultRegistry.DEFAULT_PEPPER).getFeature(session, Find.class, proxy) .withCache(cache) .find(file); } catch(VaultUnlockCancelException e) { // Continue } } } } return vault.getFeature(session, Find.class, proxy) .withCache(cache) .find(file); }
@Override public boolean find(final Path file) throws BackgroundException { try { // Look for metadata file to exist when searching for folder return delegate.withCache(new CryptoPathCache(cache)).find(vault.encrypt(session, file, file.isDirectory())); } catch(NotfoundException e) { return false; } }
/** * Rename existing file on server if there is a conflict. */ @Override public void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener) throws BackgroundException { // Rename existing file before putting new file in place if(status.isExists()) { Path rename; do { final String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.upload.file.rename.format"), FilenameUtils.getBaseName(file.getName()), UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, '-').replace(':', '-'), StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); rename = new Path(file.getParent(), proposal, file.getType()); } while(find.withCache(cache).find(rename)); if(log.isInfoEnabled()) { log.info(String.format("Rename existing file %s to %s", file, rename)); } move.move(file, rename, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback()); if(log.isDebugEnabled()) { log.debug(String.format("Clear exist flag for file %s", file)); } status.setExists(false); } super.apply(file, local, status, listener); } }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } }
/** * @return No Content-Range support */ @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e.getDetail())); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attributes = this.attributes.withCache(cache).find(file); return new Append(false, true).withSize(attributes.getSize()).withChecksum(attributes.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = this.attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attributes = this.attributes.withCache(cache).find(file); return new Append(false, true).withSize(attributes.getSize()).withChecksum(attributes.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
/** * Manta does not support raw append operations. */ @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("b2.upload.largeobject.threshold")) { if(preferences.getBoolean("b2.upload.largeobject")) { final B2LargeUploadPartService partService = new B2LargeUploadPartService(session, fileid); final List<B2FileInfoResponse> upload = partService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(B2UploadPartResponse completed : partService.list(upload.iterator().next().getFileId())) { size += completed.getContentLength(); } return new Append(size); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attributes = this.attributes.withCache(cache).find(file); return new Append(false, true).withSize(attributes.getSize()).withChecksum(attributes.getChecksum()); } return Write.notfound; } }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(finder.withCache(cache).find(vault.encrypt(session, file))) { final PathAttributes attributes = this.attributes.withCache(cache).find(vault.encrypt(session, file)); return new Append(false, true).withSize(attributes.getSize()).withChecksum(attributes.getChecksum()); } return Write.notfound; }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("openstack.upload.largeobject.threshold")) { if(preferences.getBoolean("openstack.upload.largeobject")) { long size = 0L; final List<Path> segments = listService.list(segmentService.getSegmentsDirectory(file, length), new DisabledListProgressListener()).toList(); if(segments.isEmpty()) { return Write.notfound; } for(Path segment : segments) { size += segment.attributes().getSize(); } return new Append(size); } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }