Skip to content

Commit

Permalink
Unwrap log guard condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 3, 2024
1 parent 3c8ad9c commit 535d335
Show file tree
Hide file tree
Showing 484 changed files with 1,156 additions and 3,461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ public Path copy(final Path source, final Path copy, final TransferStatus status
URI.create(blob.getUri().toString() + session.getHost().getCredentials().getToken()) : blob.getUri();
final String id = target.startCopy(s,
AccessCondition.generateEmptyCondition(), AccessCondition.generateEmptyCondition(), options, context);
if(log.isDebugEnabled()) {
log.debug("Started copy for {} with copy operation ID {}", copy, id);
}
log.debug("Started copy for {} with copy operation ID {}", copy, id);
listener.sent(status.getLength());
return copy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public boolean find(Path file, final ListProgressListener listener) throws Backg
}
}
}
if(log.isDebugEnabled()) {
log.debug("Search for common prefix {}", file);
}
log.debug("Search for common prefix {}", file);
// Check for common prefix
try {
new AzureObjectListService(session, context).list(file, new CancellingListProgressListener());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
new HostPreferences(session.getHost()).getInteger("azure.listing.chunksize"), token, options, context);
for(ListBlobItem object : result.getResults()) {
if(new SimplePathPredicate(new Path(object.getUri().getPath(), EnumSet.of(Path.Type.directory))).test(directory)) {
if(log.isDebugEnabled()) {
log.debug("Skip placeholder key {}", object);
}
log.debug("Skip placeholder key {}", object);
hasDirectoryPlaceholder = true;
continue;
}
Expand All @@ -114,9 +112,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
}
while(result.getHasMoreResults());
if(!hasDirectoryPlaceholder && children.isEmpty()) {
if(log.isWarnEnabled()) {
log.warn("No placeholder found for directory {}", directory);
}
log.warn("No placeholder found for directory {}", directory);
throw new NotfoundException(directory.getAbsolute());
}
return children;
Expand Down
8 changes: 2 additions & 6 deletions azure/src/main/java/ch/cyberduck/core/azure/AzureSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,15 @@ public void eventOccurred(final SendingRequestEvent event) {
final Proxy proxy = proxyfinder.find(new ProxyHostUrlProvider().get(host));
switch(proxy.getType()) {
case SOCKS: {
if(log.isInfoEnabled()) {
log.info("Configured to use SOCKS proxy {}", proxyfinder);
}
log.info("Configured to use SOCKS proxy {}", proxyfinder);
final java.net.Proxy socksProxy = new java.net.Proxy(
java.net.Proxy.Type.SOCKS, new InetSocketAddress(proxy.getHostname(), proxy.getPort()));
context.setProxy(socksProxy);
break;
}
case HTTP:
case HTTPS: {
if(log.isInfoEnabled()) {
log.info("Configured to use HTTP proxy {}", proxyfinder);
}
log.info("Configured to use HTTP proxy {}", proxyfinder);
final java.net.Proxy httpProxy = new java.net.Proxy(
java.net.Proxy.Type.HTTP, new InetSocketAddress(proxy.getHostname(), proxy.getPort()));
context.setProxy(httpProxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ public PathAttributes find(final Path file, final ListProgressListener listener)
if(attr.isDuplicate()) {
// Throw failure if latest version has hide marker set and lookup was without explicit version
if(StringUtils.isBlank(file.attributes().getVersionId())) {
if(log.isDebugEnabled()) {
log.debug("Latest version of {} is duplicate", file);
}
log.debug("Latest version of {} is duplicate", file);
throw new NotfoundException(file.getAbsolute());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ public DescriptiveUrl toDownloadUrl(final Path file, final Sharee sharee, final
URIEncoder.encode(containerService.getContainer(file).getName()),
URIEncoder.encode(containerService.getKey(file)));
try {
if(log.isDebugEnabled()) {
log.debug("Create download authorization for {}", file);
}
log.debug("Create download authorization for {}", file);
final int seconds = 604800;
// Determine expiry time for URL
final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ else if(file.isFile()) {
try {
if(!versioning.isEnabled() || null == file.attributes().getVersionId()) {
// Add hide marker
if(log.isDebugEnabled()) {
log.debug("Add hide marker {} of {}", file.attributes().getVersionId(), file);
}
log.debug("Add hide marker {} of {}", file.attributes().getVersionId(), file);
try {
session.getClient().hideFile(fileid.getVersionId(containerService.getContainer(file)), containerService.getKey(file));
}
Expand All @@ -109,9 +107,7 @@ else if(file.isFile()) {
}
else {
// Delete specific version
if(log.isDebugEnabled()) {
log.debug("Delete version {} of {}", file.attributes().getVersionId(), file);
}
log.debug("Delete version {} of {}", file.attributes().getVersionId(), file);
session.getClient().deleteFileVersion(containerService.getKey(file), file.attributes().getVersionId());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ public void setTokens(final String accountId, final String applicationKey, final
public void process(final HttpRequest request, final HttpContext context) {
if(StringUtils.contains(request.getRequestLine().getUri(), "b2_authorize_account")) {
// Skip setting token for
if(log.isDebugEnabled()) {
log.debug("Skip setting token in b2_authorize_account");
}
log.debug("Skip setting token in b2_authorize_account");
return;
}
switch(request.getRequestLine().getMethod()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ public Path copy(final Path source, final Path target, final TransferStatus stat
final Long length = Math.min(Math.max((size / B2LargeUploadService.MAXIMUM_UPLOAD_PARTS), partSize), remaining);
// Submit to queue
parts.add(this.submit(pool, source, response.getFileId(), status, partNumber, offset, length, callback));
if(log.isDebugEnabled()) {
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
}
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
remaining -= length;
offset += length;
}
Expand All @@ -129,9 +127,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
checksums.add(part.getContentSha1());
}
session.getClient().finishLargeFileUpload(response.getFileId(), checksums.toArray(new String[checksums.size()]));
if(log.isInfoEnabled()) {
log.info("Finished large file upload {} with {} parts", target, completed.size());
}
log.info("Finished large file upload {} with {} parts", target, completed.size());
fileid.cache(target, response.getFileId());
return target.withAttributes(new PathAttributes(source.attributes()).withVersionId(response.getFileId()));
}
Expand All @@ -150,9 +146,7 @@ private Future<B2UploadPartResponse> submit(final ThreadPool pool, final Path fi
final TransferStatus overall,
final int partNumber, final Long offset, final Long length,
final ConnectionCallback callback) {
if(log.isInfoEnabled()) {
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
}
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
return pool.execute(new DefaultRetryCallable<>(session.getHost(), new BackgroundExceptionCallable<B2UploadPartResponse>() {
@Override
public B2UploadPartResponse call() throws BackgroundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public B2LargeUploadPartService(final B2Session session, final B2VersionIdProvid
* @return File id of unfinished large upload
*/
public List<B2FileInfoResponse> find(final Path file) throws BackgroundException {
if(log.isDebugEnabled()) {
log.debug("Finding multipart uploads for {}", file);
}
log.debug("Finding multipart uploads for {}", file);
try {
final List<B2FileInfoResponse> uploads = new ArrayList<B2FileInfoResponse>();
// This operation lists in-progress multipart uploads. An in-progress multipart upload is a
Expand All @@ -83,9 +81,7 @@ public List<B2FileInfoResponse> find(final Path file) throws BackgroundException
}
}
}
if(log.isInfoEnabled()) {
log.info("Found {} previous multipart uploads for {}", uploads.size(), file);
}
log.info("Found {} previous multipart uploads for {}", uploads.size(), file);
startFileId = chunk.getNextFileId();
}
while(startFileId != null);
Expand Down Expand Up @@ -117,9 +113,7 @@ public int compare(final B2FileInfoResponse o1, final B2FileInfoResponse o2) {
* @return List of parts
*/
public List<B2UploadPartResponse> list(final String fileid) throws BackgroundException {
if(log.isInfoEnabled()) {
log.info("List completed parts of file {}", fileid);
}
log.info("List completed parts of file {}", fileid);
// This operation lists the parts that have been uploaded for a specific multipart upload.
try {
// Completed parts
Expand All @@ -146,9 +140,7 @@ public List<B2UploadPartResponse> list(final String fileid) throws BackgroundExc
* Cancel large file upload with id
*/
public void delete(final String id) throws BackgroundException {
if(log.isInfoEnabled()) {
log.info("Delete multipart upload for fileid {}", id);
}
log.info("Delete multipart upload for fileid {}", id);
try {
session.getClient().cancelLargeFileUpload(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,10 @@ public BaseB2Response upload(final Path file, final Local local,
for(int partNumber = 1; remaining > 0; partNumber++) {
boolean skip = false;
if(status.isAppend()) {
if(log.isInfoEnabled()) {
log.info("Determine if part number {} can be skipped", partNumber);
}
log.info("Determine if part number {} can be skipped", partNumber);
for(B2UploadPartResponse c : completed) {
if(c.getPartNumber().equals(partNumber)) {
if(log.isInfoEnabled()) {
log.info("Skip completed part number {}", partNumber);
}
log.info("Skip completed part number {}", partNumber);
skip = true;
offset += c.getContentLength();
break;
Expand All @@ -176,9 +172,7 @@ public BaseB2Response upload(final Path file, final Local local,
final long length = Math.min(Math.max((size / B2LargeUploadService.MAXIMUM_UPLOAD_PARTS), partSize), remaining);
// Submit to queue
parts.add(this.submit(pool, file, local, throttle, listener, status, fileId, partNumber, offset, length, callback));
if(log.isDebugEnabled()) {
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
}
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
remaining -= length;
offset += length;
}
Expand All @@ -195,9 +189,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
checksums.add(part.getContentSha1());
}
final B2FinishLargeFileResponse response = session.getClient().finishLargeFileUpload(fileId, checksums.toArray(new String[checksums.size()]));
if(log.isInfoEnabled()) {
log.info("Finished large file upload {} with {} parts", file, completed.size());
}
log.info("Finished large file upload {} with {} parts", file, completed.size());
fileid.cache(file, response.getFileId());
// Mark parent status as complete
status.withResponse(new B2AttributesFinderFeature(session, fileid).toAttributes(response)).setComplete();
Expand All @@ -219,9 +211,7 @@ private Future<B2UploadPartResponse> submit(final ThreadPool pool, final Path fi
final TransferStatus overall,
final String fileId, final int partNumber,
final Long offset, final Long length, final ConnectionCallback callback) {
if(log.isInfoEnabled()) {
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
}
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
final BytecountStreamListener counter = new BytecountStreamListener(listener);
return pool.execute(new SegmentRetryCallable<>(session.getHost(), new BackgroundExceptionCallable<B2UploadPartResponse>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ public void write(final byte[] content, final int off, final int len) throws IOE
new ByteArrayEntity(content, off, len),
checksum.algorithm == HashAlgorithm.sha1 ? checksum.hash : "do_not_verify",
overall.getMime(), fileinfo);
if(log.isDebugEnabled()) {
log.debug("Upload finished for {} with response {}", file, response);
}
log.debug("Upload finished for {} with response {}", file, response);
fileid.cache(file, response.getFileId());
finishLargeFileResponse.set(response);
close.set(true);
Expand All @@ -144,14 +142,10 @@ public void write(final byte[] content, final int off, final int len) throws IOE
if(0 == partNumber) {
startLargeFileResponse.set(session.getClient().startLargeFileUpload(fileid.getVersionId(containerService.getContainer(file)),
containerService.getKey(file), overall.getMime(), fileinfo));
if(log.isDebugEnabled()) {
log.debug("Multipart upload started for {} with ID {}", file, startLargeFileResponse.get().getFileId());
}
log.debug("Multipart upload started for {} with ID {}", file, startLargeFileResponse.get().getFileId());
}
final int segment = ++partNumber;
if(log.isDebugEnabled()) {
log.debug("Write segment {} for {}", segment, file);
}
log.debug("Write segment {} for {}", segment, file);
completed.add(new DefaultRetryCallable<B2UploadPartResponse>(session.getHost(), new BackgroundExceptionCallable<B2UploadPartResponse>() {
@Override
public B2UploadPartResponse call() throws BackgroundException {
Expand Down Expand Up @@ -218,9 +212,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
}
final B2FinishLargeFileResponse response = session.getClient().finishLargeFileUpload(
startLargeFileResponse.get().getFileId(), checksums.toArray(new String[checksums.size()]));
if(log.isInfoEnabled()) {
log.info("Finished large file upload {} with {} parts", file, completed.size());
}
log.info("Finished large file upload {} with {} parts", file, completed.size());
fileid.cache(file, response.getFileId());
finishLargeFileResponse.set(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
final Map<String, Long> revisions = new HashMap<>();
boolean hasDirectoryPlaceholder = containerService.isContainer(directory);
do {
if(log.isDebugEnabled()) {
log.debug("List directory {} with marker {}", directory, marker);
}
log.debug("List directory {} with marker {}", directory, marker);
final B2ListFilesResponse response;
if(versioning.isEnabled()) {
// In alphabetical order by file name, and by reverse of date/time uploaded for
Expand All @@ -105,9 +103,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
}
while(marker.hasNext());
if(!hasDirectoryPlaceholder && objects.isEmpty()) {
if(log.isWarnEnabled()) {
log.warn("No placeholder found for directory {}", directory);
}
log.warn("No placeholder found for directory {}", directory);
throw new NotfoundException(directory.getAbsolute());
}
return objects;
Expand Down
Loading

0 comments on commit 535d335

Please sign in to comment.