@Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { next.attributes().setSize(this.calculateSize(session, next)); } return total; }
protected PathAttributes toAttributes(final Metadata metadata) { final PathAttributes attributes = new PathAttributes(); if(metadata instanceof FileMetadata) { final FileMetadata fm = (FileMetadata) metadata; attributes.setSize(fm.getSize()); attributes.setModificationDate(fm.getClientModified().getTime()); } return attributes; } }
protected PathAttributes toAttributes(final B2FileResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(response.getContentLength()); if(response.getFileInfo().containsKey(X_BZ_INFO_LARGE_FILE_SHA1)) { attributes.setChecksum(Checksum.parse(response.getFileInfo().get(X_BZ_INFO_LARGE_FILE_SHA1))); } else { attributes.setChecksum(Checksum.parse(StringUtils.removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:"))); } final Map<String, String> metadata = new HashMap<>(); for(Map.Entry<String, String> entry : response.getFileInfo().entrySet()) { metadata.put(entry.getKey(), entry.getValue()); } attributes.setMetadata(metadata); attributes.setVersionId(response.getFileId()); if(response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate(Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } return attributes; }
protected PathAttributes toAttributes(final StorageObject object) { final PathAttributes attributes = new PathAttributes(); if(StringUtils.isNotBlank(object.getMd5sum())) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.parse(object.getMd5sum())); } attributes.setSize(object.getSize()); final String lastModified = object.getLastModified(); if(lastModified != null) { try { attributes.setModificationDate(iso8601DateParser.parse(lastModified).getTime()); } catch(InvalidDateException e) { log.warn(String.format("%s is not ISO 8601 format %s", lastModified, e.getMessage())); try { attributes.setModificationDate(rfc1123DateFormatter.parse(lastModified).getTime()); } catch(InvalidDateException f) { log.warn(String.format("%s is not RFC 1123 format %s", lastModified, f.getMessage())); } } } return attributes; }
protected final AttributedList<Path> iterate(final Iterator<OneDriveDrive.Metadata> iterator, final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> children = new AttributedList<>(); while(iterator.hasNext()) { final OneDriveDrive.Metadata metadata; try { metadata = iterator.next(); } catch(OneDriveRuntimeException e) { log.warn(e.getMessage()); continue; } final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(metadata.getId()); attributes.setSize(metadata.getTotal()); String name = metadata.getName(); if(StringUtils.isBlank(metadata.getName())) { name = metadata.getId(); } children.add(new Path(directory, name, EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); listener.chunk(directory, children); } return children; }
protected PathAttributes toAttributes(final ObjectMetadata metadata) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(Long.valueOf(metadata.getContentLength())); final String lastModified = metadata.getLastModified(); try { attributes.setModificationDate(rfc1123DateFormatter.parse(lastModified).getTime()); } catch(InvalidDateException e) { log.warn(String.format("%s is not RFC 1123 format %s", lastModified, e.getMessage())); } if(StringUtils.isNotBlank(metadata.getETag())) { final String etag = StringUtils.removePattern(metadata.getETag(), "\""); attributes.setETag(etag); if(metadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.NONE); } else { attributes.setChecksum(Checksum.parse(etag)); } } return attributes; } }
/** * @param response List filenames response from server * @return Null when respone filename is not child of working directory directory */ protected PathAttributes parse(final B2FileInfoResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setChecksum( Checksum.parse(StringUtils.removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:")) ); final long timestamp = response.getUploadTimestamp(); if(response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate(Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } else { attributes.setModificationDate(timestamp); } attributes.setVersionId(response.getFileId()); switch(response.getAction()) { case hide: // File version marking the file as hidden, so that it will not show up in b2_list_file_names case start: // Large file has been started, but not finished or canceled attributes.setDuplicate(true); attributes.setSize(-1L); break; default: attributes.setSize(response.getSize()); } return attributes; }
public PathAttributes toAttributes(final Node node) throws BackgroundException { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(String.valueOf(node.getId())); attributes.setRevision(node.getBranchVersion()); attributes.setChecksum(Checksum.parse(node.getHash())); attributes.setCreationDate(node.getCreatedAt() != null ? node.getCreatedAt().getMillis() : -1L); attributes.setModificationDate(node.getUpdatedAt() != null ? node.getUpdatedAt().getMillis() : -1L); attributes.setSize(node.getSize()); attributes.setPermission(this.toPermission(node)); attributes.setAcl(this.toAcl(node)); final Map<String, String> custom = new HashMap<>(); if(null != node.getCntDownloadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_DOWNLOADSHARES, String.valueOf(node.getCntDownloadShares())); } if(null != node.getCntUploadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_UPLOADSHARES, String.valueOf(node.getCntUploadShares())); } custom.put(SDSAttributesFinderFeature.KEY_ENCRYPTED, String.valueOf(node.getIsEncrypted())); attributes.setCustom(custom); return attributes; }
@Override public Transfer run(final Session<?> session) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Run upload action for editor %s", editor)); } final SingleTransferWorker worker = new SingleTransferWorker(session, session, upload, new TransferOptions(), new TransferSpeedometer(upload), new DisabledTransferPrompt(), callback, listener, new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledPasswordCallback(), notification); worker.run(); if(!upload.isComplete()) { log.warn(String.format("File size changed for %s", editor.getRemote())); } else { // Update known remote file size editor.getRemote().attributes().setSize(upload.getTransferred()); } return upload; }
if(!DRIVE_FOLDER.equals(f.getMimeType()) && !StringUtils.startsWith(f.getMimeType(), GOOGLE_APPS_PREFIX)) { attributes.setSize(f.getSize()); MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "HTTP"))); if(!DRIVE_FOLDER.equals(f.getMimeType()) && StringUtils.startsWith(f.getMimeType(), GOOGLE_APPS_PREFIX)) { attributes.setSize(UrlFileWriterFactory.get().write(new DescriptiveUrl(URI.create(f.getWebViewLink()))) .getBytes(Charset.defaultCharset()).length);
for(StorageObject s : segments.get(container.getName())) { final Path segment = new Path(container, s.getName(), EnumSet.of(Path.Type.file)); segment.attributes().setSize(s.getSize()); try { segment.attributes().setModificationDate(dateParser.parse(s.getLastModified()).getTime());
@Override public PathAttributes find(final Path file) throws BackgroundException { final PathAttributes attributes = new PathAttributes(delegate.withCache(new CryptoPathCache(cache)).find(vault.encrypt(session, file))); if(file.isFile()) { attributes.setSize(vault.toCleartextSize(attributes.getSize())); } return attributes; }
attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName());
@Override public PathAttributes find(final Path file) throws BackgroundException { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(file.getAbsolute()); } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(f.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); return attributes; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } }
attributes.setSize(object.getContentLength()); attributes.setETag(object.getEtag()); final byte[] md5Bytes = object.getMd5Bytes();
public PathAttributes toAttributes(final FileAttributes stat) { final PathAttributes attributes = new PathAttributes(); switch(stat.getType()) { case REGULAR: case UNKNOWN: attributes.setSize(stat.getSize()); } if(0 != stat.getMode().getPermissionsMask()) { attributes.setPermission(new Permission(Integer.toString(stat.getMode().getPermissionsMask(), 8))); } if(0 != stat.getUID()) { attributes.setOwner(String.valueOf(stat.getUID())); } if(0 != stat.getGID()) { attributes.setGroup(String.valueOf(stat.getGID())); } if(0 != stat.getMtime()) { attributes.setModificationDate(stat.getMtime() * 1000L); } if(0 != stat.getAtime()) { attributes.setAccessedDate(stat.getAtime() * 1000L); } return attributes; } }
final BasicFileAttributes a = Files.readAttributes(file, provider, LinkOption.NOFOLLOW_LINKS); if(a.isRegularFile()) { attributes.setSize(a.size());
final BlobProperties properties = blob.getProperties(); final PathAttributes attributes = new PathAttributes(); attributes.setSize(properties.getLength()); attributes.setModificationDate(properties.getLastModified().getTime()); if(StringUtils.isNotBlank(properties.getContentMD5())) {
final String sizeObj = dict.stringForKey("Size"); if(sizeObj != null) { attributes.setSize(Long.parseLong(sizeObj));
containerService.getContainer(file).getName()); final PathAttributes attributes = new PathAttributes(); attributes.setSize(info.getTotalSize()); attributes.setRegion(info.getRegion().getRegionId()); return attributes;