From 3f25406ddec011b61567708b226d98fedf256e3a Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 10 Jan 2025 08:07:06 +0100 Subject: [PATCH 1/4] Mark files with status 425. --- .../cyberduck/core/dav/DAVAttributesFinderFeature.java | 5 +++++ .../main/java/ch/cyberduck/core/dav/DAVListService.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVAttributesFinderFeature.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVAttributesFinderFeature.java index 7d6c264e129..2e262886d8f 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVAttributesFinderFeature.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVAttributesFinderFeature.java @@ -214,6 +214,11 @@ else if(resource.getModified() != null) { attributes.setDisplayname(resource.getDisplayName()); } attributes.setLockId(resource.getLockToken()); + switch(resource.getStatusCode()) { + // 425 Too Early for partial tus uploads + case 425: + attributes.setHidden(true); + } return attributes; } } diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVListService.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVListService.java index ca4818e1598..87a24c2e123 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVListService.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVListService.java @@ -73,8 +73,13 @@ public AttributedList list(final Path directory, final ListProgressListene throw new NotfoundException(directory.getAbsolute()); } final PathAttributes attr = attributes.toAttributes(resource); - final Path file = new Path(directory, PathNormalizer.name(resource.getHref().getPath()), - resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attr); + final EnumSet type = resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); + switch(resource.getStatusCode()) { + // 425 Too Early for partial tus uploads + case 425: + type.add(Path.Type.upload); + } + final Path file = new Path(directory, PathNormalizer.name(resource.getHref().getPath()), type, attr); children.add(file); listener.chunk(directory, children); } From 09c33631a8c8d51ac682bc696aaf9b24d5de16e1 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 10 Jan 2025 08:57:15 +0100 Subject: [PATCH 2/4] Parse response status from propstat. --- .../java/ch/cyberduck/core/dav/DAVClient.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java index 227e1c06aec..2f8327eddd4 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; +import org.apache.http.ParseException; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.client.CredentialsProvider; @@ -35,6 +36,7 @@ import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicLineParser; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -52,6 +54,7 @@ import com.github.sardine.impl.methods.HttpPropFind; import com.github.sardine.model.Multistatus; import com.github.sardine.model.Propfind; +import com.github.sardine.model.Propstat; import com.github.sardine.model.Response; import com.github.sardine.util.SardineUtil; @@ -122,7 +125,27 @@ public List propfind(final String url, final int depth, final Propf List resources = new ArrayList<>(responses.size()); for(Response response : responses) { try { - resources.add(new DavResource(response)); + resources.add(new DavResource(response) { + @Override + public int getStatusCode() { + List list = response.getPropstat(); + if(list.isEmpty()) { + return DEFAULT_STATUS_CODE; + } + for(Propstat propstat : list) { + if(propstat.getStatus() != null) { + try { + return BasicLineParser.parseStatusLine(propstat.getStatus(), null).getStatusCode(); + } + catch(ParseException e) { + log.warn("Failed to parse status line: {}", propstat.getStatus()); + return -1; + } + } + } + return super.getStatusCode(); + } + }); } catch(URISyntaxException e) { log.warn("Ignore resource with invalid URI {}", response.getHref().get(0)); From 3fc4464d2bf0b6f69ee204828a493b6eb11094e1 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 10 Jan 2025 09:57:00 +0100 Subject: [PATCH 3/4] Return status from response when no propstat. --- webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java index 2f8327eddd4..92a32eda613 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java @@ -129,9 +129,6 @@ public List propfind(final String url, final int depth, final Propf @Override public int getStatusCode() { List list = response.getPropstat(); - if(list.isEmpty()) { - return DEFAULT_STATUS_CODE; - } for(Propstat propstat : list) { if(propstat.getStatus() != null) { try { From b60471948fdd47df67fc65759f95acf76dad938c Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 10 Jan 2025 17:41:42 +0100 Subject: [PATCH 4/4] Update dependency.Revert "Return status from response when no propstat." This reverts commit 3fc4464d2bf0b6f69ee204828a493b6eb11094e1. --- webdav/pom.xml | 2 +- webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java | 3 +++ .../src/main/java/ch/cyberduck/core/dav/DAVQuotaFeature.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/webdav/pom.xml b/webdav/pom.xml index 2ac556dc2f6..9add8eba604 100644 --- a/webdav/pom.xml +++ b/webdav/pom.xml @@ -24,7 +24,7 @@ jar - 5.14 + 5.14.1 4.0.5.2400 diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java index 92a32eda613..2f8327eddd4 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java @@ -129,6 +129,9 @@ public List propfind(final String url, final int depth, final Propf @Override public int getStatusCode() { List list = response.getPropstat(); + if(list.isEmpty()) { + return DEFAULT_STATUS_CODE; + } for(Propstat propstat : list) { if(propstat.getStatus() != null) { try { diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVQuotaFeature.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVQuotaFeature.java index ad16222414f..fa5739ae46e 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVQuotaFeature.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVQuotaFeature.java @@ -40,6 +40,9 @@ public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); + if(null == quota) { + return Quota.unknown; + } return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE