Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark files with status 425. #16768

Merged
merged 4 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webdav/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<packaging>jar</packaging>

<properties>
<sardine-version>5.14</sardine-version>
<sardine-version>5.14.1</sardine-version>
<milton-api.version>4.0.5.2400</milton-api.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
25 changes: 24 additions & 1 deletion webdav/src/main/java/ch/cyberduck/core/dav/DAVClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -122,7 +125,27 @@ public List<DavResource> propfind(final String url, final int depth, final Propf
List<DavResource> 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<Propstat> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ public AttributedList<Path> 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<Path.Type> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading