Skip to content

Commit 22bcad3

Browse files
committed
Ensure attributes set in transfer status response have set custom attributes.
1 parent 07f3c65 commit 22bcad3

File tree

4 files changed

+11
-61
lines changed

4 files changed

+11
-61
lines changed

nextcloud/src/main/java/ch/cyberduck/core/nextcloud/NextcloudTimestampFeature.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,11 @@
1515
* GNU General Public License for more details.
1616
*/
1717

18-
import ch.cyberduck.core.Path;
1918
import ch.cyberduck.core.dav.DAVTimestampFeature;
20-
import ch.cyberduck.core.exception.BackgroundException;
21-
import ch.cyberduck.core.exception.NotfoundException;
22-
23-
import java.io.IOException;
24-
import java.util.Optional;
25-
26-
import com.github.sardine.DavResource;
2719

2820
public class NextcloudTimestampFeature extends DAVTimestampFeature {
2921

30-
private final NextcloudSession session;
31-
3222
public NextcloudTimestampFeature(final NextcloudSession session) {
33-
super(session);
34-
this.session = session;
35-
}
36-
37-
@Override
38-
protected DavResource getResource(final Path file) throws BackgroundException, IOException {
39-
final Optional<DavResource> optional = new NextcloudAttributesFinderFeature(session).list(file).stream().findFirst();
40-
if(!optional.isPresent()) {
41-
throw new NotfoundException(file.getAbsolute());
42-
}
43-
return optional.get();
23+
super(session, new NextcloudAttributesFinderFeature(session));
4424
}
4525
}

owncloud/src/main/java/ch/cyberduck/core/owncloud/OwncloudTimestampFeature.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,11 @@
1515
* GNU General Public License for more details.
1616
*/
1717

18-
import ch.cyberduck.core.Path;
1918
import ch.cyberduck.core.dav.DAVTimestampFeature;
20-
import ch.cyberduck.core.exception.BackgroundException;
21-
import ch.cyberduck.core.exception.NotfoundException;
22-
23-
import java.io.IOException;
24-
import java.util.Optional;
25-
26-
import com.github.sardine.DavResource;
2719

2820
public class OwncloudTimestampFeature extends DAVTimestampFeature {
2921

30-
private final OwncloudSession session;
31-
3222
public OwncloudTimestampFeature(final OwncloudSession session) {
33-
super(session);
34-
this.session = session;
35-
}
36-
37-
@Override
38-
protected DavResource getResource(final Path file) throws BackgroundException, IOException {
39-
final Optional<DavResource> optional = new OwncloudAttributesFinderFeature(session).list(file).stream().findFirst();
40-
if(!optional.isPresent()) {
41-
throw new NotfoundException(file.getAbsolute());
42-
}
43-
return optional.get();
23+
super(session, new OwncloudAttributesFinderFeature(session));
4424
}
4525
}

webdav/src/main/java/ch/cyberduck/core/dav/DAVTimestampFeature.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
public class DAVTimestampFeature implements Timestamp {
4545

4646
private final DAVSession session;
47+
private final DAVAttributesFinderFeature attributes;
4748

4849
public static final QName LAST_MODIFIED_DEFAULT_NAMESPACE =
4950
SardineUtil.createQNameWithDefaultNamespace("lastmodified");
@@ -62,7 +63,12 @@ public class DAVTimestampFeature implements Timestamp {
6263
SardineUtil.createQNameWithCustomNamespace("lastmodified_server");
6364

6465
public DAVTimestampFeature(final DAVSession session) {
66+
this(session, new DAVAttributesFinderFeature(session));
67+
}
68+
69+
public DAVTimestampFeature(final DAVSession session, final DAVAttributesFinderFeature attributes) {
6570
this.session = session;
71+
this.attributes = attributes;
6672
}
6773

6874
@Override
@@ -73,7 +79,7 @@ public void setTimestamp(final Path file, final TransferStatus status) throws Ba
7379
final DavResource resource = this.getResource(file);
7480
session.getClient().patch(new DAVPathEncoder().encode(file), this.getCustomProperties(resource, status.getModified()), Collections.emptyList(),
7581
this.getCustomHeaders(file, status));
76-
status.setResponse(new DAVAttributesFinderFeature(session).toAttributes(resource).setModificationDate(
82+
status.setResponse(attributes.toAttributes(resource).setModificationDate(
7783
Timestamp.toSeconds(status.getModified())));
7884
}
7985
}
@@ -92,7 +98,7 @@ public void setTimestamp(final Path file, final TransferStatus status) throws Ba
9298
* @return Latest properties
9399
*/
94100
protected DavResource getResource(final Path file) throws BackgroundException, IOException {
95-
final Optional<DavResource> optional = new DAVAttributesFinderFeature(session).list(file).stream().findFirst();
101+
final Optional<DavResource> optional = attributes.list(file).stream().findFirst();
96102
if(!optional.isPresent()) {
97103
throw new NotfoundException(file.getAbsolute());
98104
}

webdav/src/main/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVTimestampFeature.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@
1515
* GNU General Public License for more details.
1616
*/
1717

18-
import ch.cyberduck.core.Path;
1918
import ch.cyberduck.core.date.RFC1123DateFormatter;
2019
import ch.cyberduck.core.dav.DAVSession;
2120
import ch.cyberduck.core.dav.DAVTimestampFeature;
22-
import ch.cyberduck.core.exception.NotfoundException;
2321

2422
import org.w3c.dom.Element;
2523

2624
import javax.xml.namespace.QName;
27-
import java.io.IOException;
2825
import java.util.ArrayList;
2926
import java.util.List;
30-
import java.util.Optional;
3127
import java.util.TimeZone;
3228

3329
import com.github.sardine.DavResource;
@@ -41,20 +37,8 @@ public class MicrosoftIISDAVTimestampFeature extends DAVTimestampFeature {
4137

4238
public static final QName LAST_MODIFIED_WIN32_CUSTOM_NAMESPACE = new QName(MS_NAMESPACE_URI, MS_NAMESPACE_LASTMODIFIED, MS_NAMESPACE_PREFIX);
4339

44-
private final DAVSession session;
45-
4640
public MicrosoftIISDAVTimestampFeature(final DAVSession session) {
47-
super(session);
48-
this.session = session;
49-
}
50-
51-
@Override
52-
protected DavResource getResource(final Path file) throws NotfoundException, IOException {
53-
final Optional<DavResource> optional = new MicrosoftIISDAVAttributesFinderFeature(session).list(file).stream().findFirst();
54-
if(!optional.isPresent()) {
55-
throw new NotfoundException(file.getAbsolute());
56-
}
57-
return optional.get();
41+
super(session, new MicrosoftIISDAVAttributesFinderFeature(session));
5842
}
5943

6044
protected List<Element> getCustomProperties(final DavResource resource, final Long modified) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy