Skip to content

Commit 3b3b5fa

Browse files
authored
Merge pull request #15807 from iterate-ch/feature/CTERA-136-listservice
Add preflight check for list feature.
2 parents 1d6d8dc + 6204709 commit 3b3b5fa

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

core/src/main/java/ch/cyberduck/core/ListService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@
1717
* Bug fixes, suggestions and comments should be sent to [email protected]
1818
*/
1919

20+
import ch.cyberduck.core.exception.AccessDeniedException;
2021
import ch.cyberduck.core.exception.BackgroundException;
2122

23+
import java.text.MessageFormat;
24+
2225
public interface ListService {
2326
AttributedList<Path> list(Path directory, ListProgressListener listener) throws BackgroundException;
27+
28+
default void preflight(final Path directory) throws BackgroundException {
29+
if(!directory.attributes().getPermission().isExecutable() || !directory.attributes().getPermission().isReadable()) {
30+
throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Listing directory {0} failed", "Error"),
31+
directory.getName())).withFile(directory);
32+
}
33+
}
2434
}

ctera/src/main/java/ch/cyberduck/core/ctera/CteraListService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import ch.cyberduck.core.Path;
1919
import ch.cyberduck.core.dav.DAVListService;
2020
import ch.cyberduck.core.dav.DAVPathEncoder;
21+
import ch.cyberduck.core.exception.BackgroundException;
2122

2223
import java.io.IOException;
2324
import java.util.Collections;
@@ -27,8 +28,7 @@
2728

2829
import com.github.sardine.DavResource;
2930

30-
import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.ALL_ACL_QN;
31-
import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.GUID_QN;
31+
import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.*;
3232

3333
public class CteraListService extends DAVListService {
3434

@@ -45,4 +45,9 @@ protected List<DavResource> list(final Path directory) throws IOException {
4545
Stream.of(GUID_QN), ALL_ACL_QN.stream()
4646
).collect(Collectors.toSet())));
4747
}
48+
49+
@Override
50+
public void preflight(final Path directory) throws BackgroundException {
51+
assumeRole(directory, READPERMISSION);
52+
}
4853
}

0 commit comments

Comments
 (0)